def search_wikipedia(query): """Query Wikipedia and show the top hit""" gs = GoogleSearch("site:wikipedia.com %s" % query) print gs.top_result()['titleNoFormatting'] print gs.top_url() return gs.top_url()
def url_search(query, lucky=True): gs = GoogleSearch(query) try: return [gs.top_url()] if lucky else gs.top_urls() except ProxyError: raise ValueError