public void GetMetaNodesCollection_ValidHtml_ReturnHtmlNodeCollection() { var htmlDocument = HtmlAgilityPackHelper.RetrieveHtml(ValidUrl); var nodeCollection = HtmlAgilityPackHelper.GetMetaNodesCollection(htmlDocument); Assert.IsNotNull(nodeCollection); }
private int GetKeywordOccurrencesFromHtmlDocument(string keyword, string url) { if (!IsUrlValid(url)) { return(0); } var htmlDocument = HtmlAgilityPackHelper.RetrieveHtml(url); return(htmlDocument.Text.OccurrencesOf(keyword)); }
public void RetrieveHtml_InvalidUrl_ThrowsException() { try { var htmlDocument = HtmlAgilityPackHelper.RetrieveHtml(InvalidUrl); Assert.Fail("An exception should have been thrown"); } catch (Exception ex) { Assert.IsNotNull(ex); } }
private List <string> GetKeywordsFromUrl(string url) { if (!IsUrlValid(url)) { return(null); } var htmlDocument = HtmlAgilityPackHelper.RetrieveHtml(url); var metaNodes = HtmlAgilityPackHelper.GetMetaNodesCollection(htmlDocument); return(GetKeywordsFromMetaNodes(metaNodes)); }
private List <KeywordDto> GetKeywordsOccurrencesFromHtmlDocument(IEnumerable <string> keywords, string url) { if (!IsUrlValid(url)) { return(null); } var htmlDocument = HtmlAgilityPackHelper.RetrieveHtml(url); return((from keyword in keywords let occurrenceCount = htmlDocument.Text.OccurrencesOf(keyword) select new KeywordDto() { Keyword = keyword, OccurenceCount = occurrenceCount }).ToList()); }
public void RetrieveHtml_ValidUrl_ReturnHtmlDocument() { var htmlDocument = HtmlAgilityPackHelper.RetrieveHtml(ValidUrl); Assert.IsNotNull(htmlDocument); }