Example #1
0
 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     var elements = document.GetElementsOfType("h1");
     if (elements.Count() > 1)
         yield return
             GetFacet("Document contains multiple H1 tags", SEOAnalysisStatus.Error,
                 "There should only be one H1 tag in a document.");
 }
Example #2
0
        public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
        {
            var images = document.GetElementsOfType("img").ToList();

            IEnumerable<HtmlNode> imagesWithoutAlt = images.FindAll(node => !node.Attributes.Contains("alt"));

            string hasNotGotAnAltTag = _stringResourceProvider.GetValue("Admin SEO Analysis Has not got", " has not got an alt tag");
            yield return GetFacet(_stringResourceProvider.GetValue("Admin SEO Analysis Has not got alt tags", "All images have alt tags"),
                !imagesWithoutAlt.Any()
                    ? SEOAnalysisStatus.Success
                    : SEOAnalysisStatus.Error,
                imagesWithoutAlt.Select(node => node.GetAttributeValue("src", "") + hasNotGotAnAltTag).ToArray());
        }
 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     var subheadings = document.GetElementsOfType("h2").ToList();
     if (!subheadings.Any())
     {
         yield return GetFacet("Subheadings", SEOAnalysisStatus.CanBeImproved, "The page contains no subheadings (i.e. h2 tags)");
         yield break;
     }
     var matchingNodes = subheadings.FindAll(node => node.InnerHtml.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase));
     if (!matchingNodes.Any())
         yield return
             GetFacet("Subheadings", SEOAnalysisStatus.CanBeImproved, string.Format("{0} of the {1} subheadings contain the target term", matchingNodes.Count(), subheadings.Count()));
     else
         yield return
             GetFacet("Subheadings", SEOAnalysisStatus.Success, string.Format("{0} of the {1} subheadings contain the target term", matchingNodes.Count(), subheadings.Count()));
 }
 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     var paragraphs = document.GetElementsOfType("p").ToList();
     if (!paragraphs.Any())
     {
         yield return
             GetFacet("Body Content", SEOAnalysisStatus.Error,
                 string.Format("Body content contains no paragraphs of text"));
         yield break;
     }
     if (paragraphs[0].InnerText.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase))
     {
         yield return GetFacet("Body Content", SEOAnalysisStatus.Success,
             string.Format("The first paragraph contains the term '{0}'", analysisTerm));
     }
     else
     {
         yield return GetFacet("Body Content", SEOAnalysisStatus.CanBeImproved,
             string.Format("The first paragraph does not contain the term '{0}'", analysisTerm));
     }
 }