static void Main(string[] args) { //ISearch syahoo = new SearchYahoo(); //var result = syahoo.GetSearchResults("anxiety", 2); ISearch sr = new SearchGoogle(); beginTime = DateTime.Now; #if USE_ASYNC //sr.GetSearchResultsAsync("anxiety", NUM_PAGES, ProcessResult); IProcessor<ProcessorResultKWPosition> processor = new ProcessorKWPosition("helpguide.org", ResulsProcessing); //IProcessor processor = new ProcessorKWPosition("phobia-anxiety.org"); //var processor = new ProcessorKWPosition("phobia-anxiety.org", ResulsProcessing); sr.GetSearchResultsAsync("anxiety", NUM_PAGES, processor.ProcessResultAsync); #else var result = sr.GetSearchResults("anxiety", NUM_PAGES); #if USE_PARSE var endTime = DateTime.Now; var totTime = (endTime - beginTime).TotalMilliseconds; Console.WriteLine("total execution time ms: {0}", totTime); ParserBase pparser = ParserFactoryStatic.GetParser(result.SearchEngine.ToString()); var parseResults = pparser.Parse(result.SearchResponseRaw); if (parseResults != null) { for (int i = 0; i < parseResults.Count; i++) { //Console.WriteLine("links[i]: " + links[i]); Debug.WriteLine(string.Format("parseResults[{0}]: {1}", i, parseResults[i])); } } #else var links = pparser.ParseGetLinks(result.SearchResponseRaw); if (links != null) { for (int i = 0; i < links.Count; i++) { //Console.WriteLine("links[i]: " + links[i]); Debug.WriteLine(string.Format("links[{0}]: {1}", i, links[i])); } } #endif #endif Console.ReadLine(); }
protected void btnGo_Click(object sender, EventArgs e) { ISearch sr = new SearchGoogle(); var processor = new ProcessorKWPosition(txtWebsite.Text, ResulsProcessing); //sr.GetSearchResultsAsync(txtKeyword.Text, num_pages, processor.ProcessResult); var res = sr.GetSearchResults(txtKeyword.Text, 2); var processResult = processor.ProcessResult(res); int counter = 0; foreach (var item in processResult.Positions) { counter++; var tmp = string.Format("Occurance {0} at Position: {1}", counter, item); //resultStr += tmp; lstKW.Items.Add(tmp); } }