Enabled SafeSearch

This commit is contained in:
Luke Rogers 2012-04-26 12:33:55 +12:00
parent 7ab4a36379
commit ba0620aa39

View file

@ -7,7 +7,7 @@ from util.text import truncate_words
def api_get(kind, query):
"""Use the RESTful Google Search API"""
url = 'http://ajax.googleapis.com/ajax/services/search/%s?' \
'v=1.0&safe=off'
'v=1.0&safe=moderate'
return http.get_json(url % kind, q=query)
@ -15,7 +15,7 @@ def api_get(kind, query):
@hook.command('gis')
@hook.command
def googleimage(inp):
".gis <term> -- Returns first Google Image result (Safesearch off)."
".gis <query> -- Returns first Google Image result for <query>."
parsed = api_get('images', inp)
if not 200 <= parsed['responseStatus'] < 300:
@ -52,8 +52,6 @@ def google(inp):
out = '%s -- \x02%s\x02: "%s"' % (result['unescapedUrl'], title, content)
out = ' '.join(out.split())
out = truncate_words(out, 300)
return out