private IEnumerable<GoogleSearchResult> ParseResult(string webResult) { var result = new List<GoogleSearchResult>(); try { var doc = new HtmlDocument(); doc.LoadHtml(webResult); var nodes = doc.DocumentNode.SelectNodes("//li[@class='g']"); foreach (var n in nodes) { var gsr = new GoogleSearchResult(); var aNode = n.SelectSingleNode(".//h3[@class='r']/a"); gsr.Title = StripHTML(HttpUtility.HtmlDecode(aNode.InnerText)); gsr.Url = GetUrl(aNode.GetAttributeValue("href", string.Empty)); Uri uri; if (Uri.TryCreate(gsr.Url, UriKind.Absolute, out uri)) { result.Add(gsr); } } } catch { } return result; }
private SearchResultListItem MapGoogleSearch(GoogleSearchResult gsr) { return new SearchResultListItem { Text = gsr.Title, Url = gsr.Url }; }