def google_search_task(query, language="en", num_results=10): # languages: spahish:'es' ; german:'de', etc... logging.basicConfig(level=logging.DEBUG) try: google = GoogleSearch(query, True, False, language) google.results_per_page = num_results query_results = google.get_results() last_query_time = time.time() logging.info( "celerytask::GoogleSearch::querying " + query + " last_query_time:: " + time.ctime(last_query_time) ) resulting_snippets = [] for r in query_results: title = r.title.encode("utf8") description = r.desc.encode("utf8") url = r.url.encode("utf8") snippet = (title, description, url) resulting_snippets.append(snippet) logging.info("celerytask::GoogleSearch::fetching <<" + str(len(query_results)) + ">> resulting snippets") return resulting_snippets except SearchError, e: raise google_search_task.retry(exc=e)
# -*- coding: utf8 -*- # This program is part of CIDESAL.incubator.iteration 1 __author__ = "Jorge García Flores" __date__ = "$03-abr-2011 10:05:30$" import sys from xgoogle_unoporuno.search import GoogleSearch, SearchError print "bonjour tout le monde" gs = GoogleSearch(sys.argv[1], True, False, "fr") gs.results_per_page = 10 results = gs.get_results() print len(results) for r in results: titulo = r.title.encode("utf-8") descripcion = r.desc.encode("utf-8") url = r.url.encode("utf-8") print "--------" print "TITLE:", titulo print "DESC:", descripcion print "URL:", url
# -*- coding: utf8 -*- # This program is part of CIDESAL.incubator.iteration 1 __author__="Jorge García Flores" __date__ ="$03-abr-2011 10:05:30$" import sys from xgoogle_unoporuno.search import GoogleSearch, SearchError print 'bonjour tout le monde' gs = GoogleSearch(sys.argv[1], True, False, 'fr') gs.results_per_page = 10 results = gs.get_results() print len(results) for r in results: titulo = r.title.encode('utf-8') descripcion = r.desc.encode('utf-8') url = r.url.encode('utf-8') print '--------' print 'TITLE:', titulo print 'DESC:', descripcion print 'URL:', url