fix wiktionary no results error handling

This commit is contained in:
mutantmonkey
2012-06-07 18:17:55 -07:00
parent 931b53a974
commit cf53da9d6e
2 changed files with 19 additions and 1 deletions

View File

@@ -38,7 +38,11 @@ def wiktionary(word):
pages = json.loads(bytes)
pages = pages['query']['pages']
pg = next(iter(pages))
result = pages[pg]['revisions'][0]['*']
try:
result = pages[pg]['revisions'][0]['*']
except KeyError:
return '', ''
mode = None
etymology = None