diff --git a/requirements.txt b/requirements.txt index d131efd..527ca95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ spicemanip>=0.1.6 gitpython pygit2 fake-useragent +googlesearch diff --git a/sopel_modules/SpiceBot/Google.py b/sopel_modules/SpiceBot/Google.py index c1ffffe..ec4725f 100644 --- a/sopel_modules/SpiceBot/Google.py +++ b/sopel_modules/SpiceBot/Google.py @@ -5,6 +5,8 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import requests from fake_useragent import UserAgent +import googlesearch + # TODO add a cache flush @@ -21,6 +23,12 @@ class Google(): # losercase searching searchterm = searchterm.lower() + """ + safe='off', + """ + + return str(googlesearch.lucky(searchterm):) + # check cache if searchtype not in list(self.cache.keys()): self.cache[searchtype] = dict() @@ -34,6 +42,8 @@ class Google(): if searchtype == 'maps': var = requests.get(r'http://www.google.com/maps/place/' + lookfor, headers=header) elif searchtype == 'info': + var = requests.get(r'https://www.youtube.com/search?q=' + lookfor + '&btnI', headers=header) + elif searchtype == 'youtube': var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header) else: var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)