diff options
-rwxr-xr-x | bladictionary.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bladictionary.py b/bladictionary.py index 7a3112a..c3ee7db 100755 --- a/bladictionary.py +++ b/bladictionary.py @@ -8,7 +8,7 @@ from lxml import etree import sqlite3 import requests -VERSION = "2.3.2" +VERSION = "2.3.3" class Definition(object): #ID is relative to the word type, eg noun 1, noun 2, verb 1, verb 2, not to the entire list @@ -426,13 +426,17 @@ def parse_foldoc(word, refer = None): return items def parse_urban(word): - r = requests.get("http://urbanscraper.herokuapp.com/search/" + word) - json = r.json() + try: + r = requests.get("http://urbanscraper.herokuapp.com/search/" + word) + json = r.json() + except: + #Should probably print an error, but then that would break printing other definitions, so let's not + return items = [] id = 1 - for json_item in json: + print json_item if json_item['definition'] != "" and json_item['definition'] is not None: item = Definition(word, id, "urban", "urban", json_item['definition'], [json_item['example']], [], []) items.append(item) |