def add_link(m): text = m[1] try: print(' - text :', text) link = googlesearch.lucky(site_filter + text) print(' link :', link) return '[' + m[1] + '](' + link + ')' except Exception as e: print(' error :', e) return m[0]
def Baixar(): jogo = googlesearch.lucky('emuparadise.me download' + str(nome.get()), tld='me') print(jogo) emuParadise = regex.compile(r'(https://www.emuparadise.me/)' + '([\S--/]+)/' + '([\S--/]+/)' + '(\d+)') mb = emuParadise.search(str(jogo)) numero = mb.group(4) output = 'https://www.emuparadise.me/roms/get-download.php?gid=' + numero + '&test=true' webbrowser.open(str(output))
def search(query, tld='com', lang='en', tbs='0', safe='off', num=10, start=0, stop=1, domains=None, pause=2.0, only_standard=False, extra_params={}, tpe='', user_agent=None, type='none', rights='', download=False, path=None, out_format="html"): if (type == 'text' or type == 'none' or type is None): # normal search if download: p = "downloads" if path is not None: p = path return Download( googlesearch.search(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params, tpe, user_agent), p, out_format) else: return googlesearch.search( query, tld, lang, tbs, safe, num, start, stop, pause, domains, # country #only_standard, extra_params, #tpe, user_agent #ssl ) ''' Return type: generator of str Returns: Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever. ''' elif (type == 'image_home'): # image search if download: p = "downloads" if path is not None: p = path return Download( googlesearch.search_images(query, tld, lang, tbs, safe, num, start, stop, pause, domains, only_standard, extra_params), p, out_format) else: return googlesearch.search_images(query, tld, lang, tbs, safe, num, start, stop, pause, domains, only_standard, extra_params) ''' Return type: generator of str Returns: Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever. ''' elif (type == 'image' or type == 'images'): response = google_images_download.googleimagesdownload( ) #class instantiation if lang == "sv": language = "Swedish" else: language = "English" arguments = { "keywords": query, "limit": num, "print_urls": "false", "language": language } # add rights if rights in [ "labeled-for-reuse-with-modifications", "labeled-for-reuse", "labeled-for-noncommercial-reuse-with-modification", "labeled-for-nocommercial-reuse" ]: arguments["usage_rights"] = rights # add safe if safe == "true": arguments["safe_search"] = safe if download: if path is not None: arguments["output_directory"] = path else: arguments["no_download"] = "true" arguments["no_directory"] = "true" ''' This one is a little special, Here we instead use google_images_download library Used to download images directly! ''' return response.download( arguments) #passing the arguments to the function elif (type == 'video' or type == 'film' or type == 'movie'): # video search if download: p = "downloads" if path is not None: p = path return Download( googlesearch.search_videos(query, tld, lang, tbs, safe, num, start, stop, pause, domains, only_standard, extra_params), p, out_format) else: return googlesearch.search_videos(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params) ''' Return type: generator of str Returns: Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever. ''' elif (type == 'news'): # search news if download: p = "downloads" if path is not None: p = path return Download( googlesearch.search_news(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params), p, out_format) else: return googlesearch.search_news(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params) ''' Return type: generator of str Returns: Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever. ''' elif (type == 'lucky'): # i am luchy search if download: p = "downloads" if path is not None: p = path return Download( googlesearch.lucky(query, tld, lang, tbs, safe, only_standard, extra_params, tpe), p, out_format) else: return googlesearch.lucky(query, tld, lang, tbs, safe, only_standard, extra_params, tpe) ''' Return type: str Returns: URL found by Google. ''' elif (type == 'shop'): # if download: p = "downloads" if path is not None: p = path return Download( googlesearch.search_shop(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params), p, out_format) else: return googlesearch.search_shop(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params) ''' Return type: generator of str Returns: Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever. ''' elif (type == 'app' or type == 'apps'): # search apps if download: p = "downloads" if path is not None: p = path return Download( googlesearch.search_apps(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params), p, out_format) else: return googlesearch.search_apps(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params) ''' Return type: generator of str Returns: Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever. ''' elif (type == 'books' or type == 'book'): # book search if download: p = "downloads" if path is not None: p = path return Download( googlesearch.search_books(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params), p, out_format) else: return googlesearch.search_books(query, tld, lang, tbs, safe, num, start, stop, domains, pause, only_standard, extra_params) ''' Return type: generator of str Returns: Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever. ''' else: raise Exception("Unsupported type as parameter to search function!")
def search(query): link=gs.lucky(query) engine.say("Here's the result from google search: ") engine.runAndWait() print("Here's the result from google search: "+ link)
import googlesearch print(googlesearch.lucky('mail.md'))