Exemplo n.º 1
0
        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();

        }
Exemplo n.º 2
0
 private void InitParser(ISearchResult _result)
 {
     parser       = ParserFactoryStatic.GetParser(_result.SearchEngine.ToString());
     parseResults = parser.Parse(_result.SearchResponseRaw);
 }