public void LoadPage_ShouldLoadXmlWebPageData()
        {
            //Act
            var actual = WebPageHelper.LoadPage("https://www.w3schools.com/xml/plant_catalog.xml");

            //Assert
            Assert.NotNull(actual);
        }
        public void LoadPage_ShouldLoadHtmlWebPageData()
        {
            //Act
            var actual = WebPageHelper.LoadPage("http://www.facebook.com");

            //Assert
            Assert.NotNull(actual);
        }
예제 #3
0
        public IEnumerable <IGrouping <string, HtmlNode> > GetTags(string url)
        {
            content = WebPageHelper.LoadPage(url);

            tags = content.DocumentNode.Descendants().ToList();

            var groupedTags = tags
                              .Where(x => x.NodeType == HtmlNodeType.Element)
                              .GroupBy(x => x.Name);

            if (groupedTags.Count() > 0)
            {
                Console.WriteLine(" Unique tags found:");

                foreach (var tag in groupedTags)
                {
                    Console.WriteLine($" Name: {tag.Key} with {tag.Count()} occurrences.");
                }

                Console.WriteLine("  ");
            }

            return(groupedTags);
        }