private IList <Word> ReadWordsAgilityPack(HtmlNode node, User adminUser) { var tableRows = node.FindNodes(By.XPath("/html/body//div[@class='results']/table/tbody/tr")); var wordListing = new List <Word>(); foreach (var row in tableRows) { var rowTD = row.FindNodes(By.TagName("td")); var wordText = rowTD[0].InnerText.Trim().ToUpper(); var userId = rowTD[3].InnerText.Trim(); var date = rowTD[4].InnerText.Trim(); var word = new Word { Language = "no", Value = wordText, NumberOfLetters = ScraperUtils.CountNumberOfLetters(wordText), NumberOfWords = ScraperUtils.CountNumberOfWords(wordText), User = adminUser, CreatedDate = ScraperUtils.ParseDateTimeOrNow(date, "yyyy-MM-dd"), Source = this.source, Comment = "User " + userId }; wordListing.Add(word); } return(wordListing); }
private IList <Word> ReadRelatedWordsAgilityPack(HtmlNode node, User adminUser) { // parse all related words var tableRows = node.FindNodes(By.XPath("/html/body//div[@class='results']/table/tbody/tr")); var relatedWords = new List <Word>(); if (tableRows == null) { return(relatedWords); } foreach (var row in tableRows) { var rowTD = row.FindNodes(By.TagName("td")); var hintText = rowTD[0].InnerText.Trim().ToUpper(); var userId = rowTD[3].InnerText.Trim(); var date = rowTD[4].InnerText.Trim(); var hint = new Word { Language = "no", Value = hintText, NumberOfLetters = ScraperUtils.CountNumberOfLetters(hintText), NumberOfWords = ScraperUtils.CountNumberOfWords(hintText), User = adminUser, CreatedDate = ScraperUtils.ParseDateTimeOrNow(date, "yyyy-MM-dd"), Source = this.source, Comment = "User " + userId }; relatedWords.Add(hint); } relatedWords = relatedWords.Distinct().ToList(); // Note that this requires the object to implement IEquatable<Word> return(relatedWords); }