/// <summary> /// Get search results for a given search term /// </summary> /// <param name="searchTerm">The search term to find search results for</param> /// <returns>A collection of search results</returns> public IEnumerable <SearchResult> GetSearchResults(string searchTerm) { var encodedSearchTerm = this.queryStringEncoder.Encode(searchTerm); var urlQuery = this.searchEngineUrl + encodedSearchTerm; var document = this.htmlParser.Parse(urlQuery); var content = document.QuerySelectorAll(searchResultSelector); var searchResults = new List <SearchResult>(); if (content != null) { //TODO: parallel foreach? foreach (var c in content) { var url = searchEngineSelector.GetUrl(c); var title = searchEngineSelector.GetTitle(c); var text = searchEngineSelector.GetCaption(c); if (!String.IsNullOrEmpty(url) && !String.IsNullOrEmpty(title)) { searchResults.Add(new SearchResult() { Title = title, Caption = text, Url = url }); } } } return(searchResults); }