本文整理汇总了C#中HtmlAgilityPack.HtmlNode.GetElementText方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNode.GetElementText方法的具体用法?C# HtmlNode.GetElementText怎么用?C# HtmlNode.GetElementText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlAgilityPack.HtmlNode
的用法示例。
在下文中一共展示了HtmlNode.GetElementText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFacets
public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
{
string titleText = document.GetElementText("title") ?? string.Empty;
if (titleText.Length < 50)
yield return GetFacet("Title length", SEOAnalysisStatus.Error, "The title should be at least 50 characters long");
else if (titleText.Length > 90)
yield return
GetFacet("Title length", SEOAnalysisStatus.Error, "The title should be at most 90 characters long");
else
yield return
GetFacet("Title length", SEOAnalysisStatus.Success,
"The title is of optimal length (50-90 characters)");
}
示例2: GetFacets
public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
{
var element = document.GetElement("h1");
if (element == null)
{
yield return GetFacet("H1 is missing", SEOAnalysisStatus.Error, "The H1 element is missing in the page");
yield break;
}
string h1Text = document.GetElementText("h1");
if (h1Text.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase))
yield return
GetFacet("H1 contains term", SEOAnalysisStatus.Success,
"The H1 element contains '" + analysisTerm + "'");
else
yield return
GetFacet("H1 contains term", SEOAnalysisStatus.Error,
"The H1 element does not contain '" + analysisTerm + "'");
}
示例3: GetFacets
public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
{
string titleText = document.GetElementText("title");
if (titleText != null && titleText.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase))
{
if (titleText.StartsWith(analysisTerm))
yield return
GetFacet("Title contains term", SEOAnalysisStatus.Success,
string.Format("The title starts with the term '{0}', which is considered to improve rankings", analysisTerm));
else
{
yield return
GetFacet("Title contains term", SEOAnalysisStatus.CanBeImproved,
string.Format(
"The title contains the term '{0}'. To improve this, consider moving it to the start of the title, as this is considered to improve rankings",
analysisTerm));
}
}
else
yield return
GetFacet("Title contains term", SEOAnalysisStatus.Error,
string.Format("The title does not contain '{0}'", analysisTerm));
}