public async Task GetMatchingURLs_should_return_null_on_Bing_for_vjdotcom() { WebScrapper ws = new WebScrapper(); var results = await ws.GetMatchingURLs("test", Core.Enums.SearchEngine.Bing, new Uri("https://vj.com")); Assert.IsTrue(!results.Any()); }
public async Task GetMatchingURLs_should_return_result_on_Bing_for_InfoTrack() { WebScrapper ws = new WebScrapper(); var results = await ws.GetMatchingURLs("test", Core.Enums.SearchEngine.Bing, new Uri("https://www.infotrack.com.au")); Assert.IsTrue(results.Any()); }
public async Task <SearchOccurrence> Search(string keywords, Uri url, SearchEngine searchEngine) { _logger.LogInformation("Calling Search method"); var scrapeResults = await _webScrapper.GetMatchingURLs(keywords, searchEngine, url); var result = new SearchOccurrence { //If there is no result available, add 0 into the array Occurrences = scrapeResults.Any() ? scrapeResults.Select(s => s.Index).ToArray() : new int[] { 0 }, SearchEngine = searchEngine, URL = url.ToString() }; return(result); }