Fixed the suggest plugin

The API get request needed to be tweaked.
This commit is contained in:
stoneLeaf 2012-04-12 03:41:35 +02:00
parent 3c9e6a6736
commit 25116e20f9
1 changed files with 2 additions and 2 deletions

View File

@ -19,7 +19,7 @@ def suggest(inp, inp_unstripped=''):
else: else:
num = 0 num = 0
page = http.get('http://google.com/complete/search', q=inp) page = http.get('http://google.com/complete/search', output='json', client='hp', q=inp)
page_json = page.split('(', 1)[1][:-1] page_json = page.split('(', 1)[1][:-1]
suggestions = json.loads(page_json)[1] suggestions = json.loads(page_json)[1]
if not suggestions: if not suggestions:
@ -30,4 +30,4 @@ def suggest(inp, inp_unstripped=''):
out = suggestions[num - 1] out = suggestions[num - 1]
else: else:
out = random.choice(suggestions) out = random.choice(suggestions)
return '#%d: %s' % (int(out[2][0]) + 1, out[0]) return '#%d: %s' % (int(out[2][0]) + 1, out[0].replace('<b>', '').replace('</b>', ''))