Switched suggest API
This commit is contained in:
parent
6d147e1677
commit
97a3283eff
|
@ -15,7 +15,7 @@ phrases = [
|
||||||
u"YOU WON'T NOT MAKE SOME FUCKING \x02{}\x02",
|
u"YOU WON'T NOT MAKE SOME FUCKING \x02{}\x02",
|
||||||
u"HOW ABOUT SOME FUCKING \x02{}?\x02",
|
u"HOW ABOUT SOME FUCKING \x02{}?\x02",
|
||||||
u"WHY DON'T YOU EAT 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"
|
u"INDUCE FOOD COMA WITH SOME FUCKING \x02{}\x02"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import json
|
|
||||||
|
|
||||||
from util import hook, http, text
|
from util import hook, http, text
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
@ -7,20 +5,14 @@ from bs4 import BeautifulSoup
|
||||||
@hook.command
|
@hook.command
|
||||||
def suggest(inp):
|
def suggest(inp):
|
||||||
"""suggest <phrase> -- Gets suggested phrases for a google search"""
|
"""suggest <phrase> -- Gets suggested phrases for a google search"""
|
||||||
|
suggestions = http.get_json('http://suggestqueries.google.com/complete/search', client='firefox', q=inp)[1]
|
||||||
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]
|
|
||||||
|
|
||||||
if not suggestions:
|
if not suggestions:
|
||||||
return 'no suggestions found'
|
return 'no suggestions found'
|
||||||
|
|
||||||
out = u", ".join(suggestions)
|
out = u", ".join(suggestions)
|
||||||
|
|
||||||
# defuckify text
|
# defuckify text (might not be needed now, but I'll keep it)
|
||||||
soup = BeautifulSoup(out)
|
soup = BeautifulSoup(out)
|
||||||
out = soup.get_text()
|
out = soup.get_text()
|
||||||
|
|
||||||
|
|
Reference in New Issue