Switched suggest API

This commit is contained in:
Luke Rogers 2014-04-02 23:22:39 +13:00
parent 6d147e1677
commit 97a3283eff
2 changed files with 3 additions and 11 deletions

View File

@ -15,7 +15,7 @@ phrases = [
u"YOU WON'T NOT MAKE SOME FUCKING \x02{}\x02",
u"HOW ABOUT SOME FUCKING \x02{}?\x02",
u"WHY DON'T YOU EAT SOME FUCKING \x02{}?\x02",
u"MAKE SOME FUCKING \x02{}\x02",
u"MAKE SOME FUCKING \x02{}\x02", v
u"INDUCE FOOD COMA WITH SOME FUCKING \x02{}\x02"
]

View File

@ -1,5 +1,3 @@
import json
from util import hook, http, text
from bs4 import BeautifulSoup
@ -7,20 +5,14 @@ from bs4 import BeautifulSoup
@hook.command
def suggest(inp):
"""suggest <phrase> -- Gets suggested phrases for a google search"""
page = http.get('http://google.com/complete/search',
output='json', client='hp', q=inp)
page_json = page.split('(', 1)[1][:-1]
suggestions = json.loads(page_json)[1]
suggestions = [suggestion[0] for suggestion in suggestions]
suggestions = http.get_json('http://suggestqueries.google.com/complete/search', client='firefox', q=inp)[1]
if not suggestions:
return 'no suggestions found'
out = u", ".join(suggestions)
# defuckify text
# defuckify text (might not be needed now, but I'll keep it)
soup = BeautifulSoup(out)
out = soup.get_text()