This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/disabled_stuff/suggest.py

20 lines
543 B
Python
Raw Normal View History

2014-02-23 08:33:08 +01:00
from util import hook, http, text
from bs4 import BeautifulSoup
@hook.command
def suggest(inp):
"""suggest <phrase> -- Gets suggested phrases for a google search"""
2014-04-02 12:22:39 +02:00
suggestions = http.get_json('http://suggestqueries.google.com/complete/search', client='firefox', q=inp)[1]
2014-02-23 08:33:08 +01:00
if not suggestions:
return 'no suggestions found'
out = u", ".join(suggestions)
2014-04-02 12:22:39 +02:00
# defuckify text (might not be needed now, but I'll keep it)
2014-02-23 08:33:08 +01:00
soup = BeautifulSoup(out)
out = soup.get_text()
return text.truncate_str(out, 200)