Example #1
0
def imsearch_query(query, query_params, query_timeout=-1.0, engine='google_web'):
    # prepare input arguments for searcher initialization if non-default
    searcher_args = dict()
    if query_timeout > 0.0:
        searcher_args['timeout'] = query_timeout
    # initialize searcher
    if engine == 'google_web':
        searcher = image_query.GoogleWebSearch(**searcher_args)
    else:
        raise ValueError('Unkown query engine')
    # execute the query
    return searcher.query(query, **query_params)
Example #2
0
    google_api_results = google_api_searcher.query(test_query_str)
    google_api_timing = time.time() - t
    print 'Retrieved %d results in %f seconds' % (len(google_api_results),
                                                  google_api_timing)

    result_page_gen.gen_results_page(google_api_results,
                                     'GoogleAPISearch()',
                                     os.path.join(outdir,
                                                  'google_api_results.html'),
                                     show_in_browser=False)

    all_results.append(google_api_results)
    all_generator_names.append('GoogleAPISearch()')

if test_google_web:
    google_web_searcher = image_query.GoogleWebSearch()
    print 'Executing Google Web Search...'
    t = time.time()
    google_web_results = google_web_searcher.query(test_query_str)
    google_web_timing = time.time() - t
    print 'Retrieved %d results in %f seconds' % (len(google_web_results),
                                                  google_web_timing)

    result_page_gen.gen_results_page(google_web_results,
                                     'GoogleWebSearch()',
                                     os.path.join(outdir,
                                                  'google_web_results.html'),
                                     show_in_browser=False)

    all_results.append(google_web_results)
    all_generator_names.append('GoogleWebSearch()')
 def setup(self):
     self._gws = image_query.GoogleWebSearch(False)
     self._q = 'polka dots'