private void AnalyzeHeadTag(HtmlNode headTag) { try { var titleTag = _htmlTagHelper.GetTitleTag(headTag); AnalyzeTitleTag(titleTag); } catch (NoElementFoundException e) { AddResultRule("no_" + e.ElementName + "_tag", ResultType.Error); } catch (MultipleElementsFoundException e) { AddResultRule("multiple_" + e.ElementName + "_tags", ResultType.Error); } }
public override void Analyse(IPageData pageData) { if (pageData == null) { throw new ArgumentNullException(nameof(pageData)); } try { var titleTag = _htmlTagHelper.GetTitleTag(pageData.Document); var titleText = titleTag.InnerText; var position = titleText.IndexOf(pageData.Focuskeyword, StringComparison.InvariantCultureIgnoreCase); if (position >= 0) { if (position < IdealKeywordPosition) { AddResultRule("title_contains_keyword", ResultType.Success); } else { AddResultRule("title_not_in_front", ResultType.Hint); } } else { AddResultRule("title_doesnt_contain_keyword", ResultType.Warning); } } catch (NoElementFoundException e) { AddResultRule("no_" + e.ElementName + "_tag", ResultType.Error); } catch (MultipleElementsFoundException e) { AddResultRule("multiple_" + e.ElementName + "_tags", ResultType.Error); } }