mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
google search
This commit is contained in:
parent
822a9c8262
commit
132cdda94a
@ -5,8 +5,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
|||||||
import requests
|
import requests
|
||||||
from fake_useragent import UserAgent
|
from fake_useragent import UserAgent
|
||||||
|
|
||||||
from google import search as gsearch
|
|
||||||
|
|
||||||
# TODO add a cache flush
|
# TODO add a cache flush
|
||||||
|
|
||||||
|
|
||||||
@ -27,8 +25,6 @@ class Google():
|
|||||||
safe='off',
|
safe='off',
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return str(gsearch(searchterm))
|
|
||||||
|
|
||||||
# check cache
|
# check cache
|
||||||
if searchtype not in list(self.cache.keys()):
|
if searchtype not in list(self.cache.keys()):
|
||||||
self.cache[searchtype] = dict()
|
self.cache[searchtype] = dict()
|
||||||
@ -42,9 +38,12 @@ class Google():
|
|||||||
if searchtype == 'maps':
|
if searchtype == 'maps':
|
||||||
var = requests.get(r'http://www.google.com/maps/place/' + lookfor, headers=header)
|
var = requests.get(r'http://www.google.com/maps/place/' + lookfor, headers=header)
|
||||||
elif searchtype == 'info':
|
elif searchtype == 'info':
|
||||||
var = requests.get(r'https://www.youtube.com/search?q=' + lookfor + '&btnI', headers=header)
|
url = "http://www.google.com"
|
||||||
|
query = {'q': searchterm}
|
||||||
|
var = requests.get(url, params=query)
|
||||||
|
# var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)
|
||||||
elif searchtype == 'youtube':
|
elif searchtype == 'youtube':
|
||||||
var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)
|
var = requests.get(r'https://www.youtube.com/search?q=' + lookfor + '&btnI', headers=header)
|
||||||
else:
|
else:
|
||||||
var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)
|
var = requests.get(r'http://www.google.com/search?q=' + lookfor + '&btnI', headers=header)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user