public void HtmlParser_Test() { string html = File.ReadAllText(@"Sample Data\SampleResults.html"); string results = HtmlParser.FindAllHrefMatches(html, new Uri("https://www.infotrack.com.au")); Assert.IsTrue(results != "0"); }
public void HtmlParser_GoogleResults_Test() { string html = File.ReadAllText(@"Sample Data\GoogleSampleResults.html"); string results = HtmlParser.FindAllHrefMatches(html, new Uri("https://www.Sympli.com.au"), _googleParseFields); Assert.IsTrue(results != "0"); }
public string SearchUrls(SearchInput searchInput) { Uri searchUri = new Uri($"https://{searchInput.SearchUrl}/"); string searchUrl = "https://www.google.com/search?num=100&q={0}&btnG=Search"; string requestString = string.Format(searchUrl, HttpUtility.UrlEncode(searchInput.SearchText)); WebRequest request = WebRequest.Create(requestString); using (WebResponse response = request.GetResponse()) { using (Stream dataStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd(); reader.Close(); return(HtmlParser.FindAllHrefMatches(responseFromServer, searchUri)); } } }