mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 15:09:54 -05:00
test googlesearch api
This commit is contained in:
parent
961c25be78
commit
a4a564a5fd
@ -2,3 +2,4 @@ spicemanip>=0.1.6
|
|||||||
gitpython
|
gitpython
|
||||||
pygit2
|
pygit2
|
||||||
fake-useragent
|
fake-useragent
|
||||||
|
googlesearch
|
||||||
|
|||||||
@ -5,6 +5,8 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
|||||||
import requests
|
import requests
|
||||||
from fake_useragent import UserAgent
|
from fake_useragent import UserAgent
|
||||||
|
|
||||||
|
import googlesearch
|
||||||
|
|
||||||
# TODO add a cache flush
|
# TODO add a cache flush
|
||||||
|
|
||||||
|
|
||||||
@ -21,6 +23,12 @@ class Google():
|
|||||||
# losercase searching
|
# losercase searching
|
||||||
searchterm = searchterm.lower()
|
searchterm = searchterm.lower()
|
||||||
|
|
||||||
|
"""
|
||||||
|
safe='off',
|
||||||
|
"""
|
||||||
|
|
||||||
|
return str(googlesearch.lucky(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()
|
||||||
@ -34,6 +42,8 @@ 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)
|
||||||
|
elif searchtype == 'youtube':
|
||||||
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)
|
||||||
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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user