本文整理汇总了C#中HtmlAgilityPack.HtmlNode.ChildNodesRecursive方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNode.ChildNodesRecursive方法的具体用法?C# HtmlNode.ChildNodesRecursive怎么用?C# HtmlNode.ChildNodesRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlAgilityPack.HtmlNode
的用法示例。
在下文中一共展示了HtmlNode.ChildNodesRecursive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetFacets
public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
{
var descriptionElement = document.ChildNodesRecursive().FirstOrDefault(node => node.Name == "meta" && node.GetAttributeValue("name","") == "description");
string metaDescription = descriptionElement != null
? descriptionElement.GetAttributeValue("content", "")
: string.Empty;
if (string.IsNullOrWhiteSpace(metaDescription))
{
yield return GetFacet("Meta description set", SEOAnalysisStatus.Error, "No meta description has been set - search engines will instead use text from your copy in results");
yield break;
}
yield return GetFacet("Meta description set", SEOAnalysisStatus.Success, "Meta description is set");
yield return
metaDescription.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase)
? GetFacet("Meta description contains analysis term", SEOAnalysisStatus.Success, string.Format("Meta description contains '{0}'", analysisTerm))
: GetFacet("Meta description contains analysis term", SEOAnalysisStatus.Error, string.Format("Meta description does not contain '{0}'", analysisTerm));
if (metaDescription.Length < 120)
{
yield return
GetFacet("Meta description length", SEOAnalysisStatus.CanBeImproved,
"Meta description should be at least 120 characters");
}
else if (metaDescription.Length > 200)
{
yield return
GetFacet("Meta description length", SEOAnalysisStatus.Error,
"Meta description should be at most 200 characters");
}
else
{
yield return
GetFacet("Meta description length", SEOAnalysisStatus.Success,
"Meta description is of optimal length (between 120 and 200 characters)");
}
bool anyWithSameDescription =
_session.QueryOver<Webpage>()
.Where(page => page.Site.Id == webpage.Site.Id && page.Id != webpage.Id && page.MetaDescription == webpage.MetaDescription)
.Any();
if (anyWithSameDescription)
yield return
GetFacet("Any other pages with same meta description?", SEOAnalysisStatus.Error, "The meta description is not unique");
else
yield return
GetFacet("Any other pages with same meta description?", SEOAnalysisStatus.Success, "The meta description is unique");
}
开发者ID:neozhu,项目名称:MrCMS,代码行数:46,代码来源:MetaDescriptionChecks.cs本文标签属性:
示例:示例志愿表
代码:代码生成器
HtmlNode:HtmlNode
ChildNodesRecursive:ChildNodesRecursive