[mod] add more error handling to json engine

This commit is contained in:
Adam Tauber 2017-11-02 00:43:29 +01:00
parent ddeea6386b
commit 181f1c6305

View file

@ -98,10 +98,16 @@ def response(resp):
results = [] results = []
json = loads(resp.text) json = loads(resp.text)
if results_query: if results_query:
for result in query(json, results_query)[0]: rs = query(json, results_query)
if not len(rs):
return results
for result in rs[0]:
url = query(result, url_query)[0] url = query(result, url_query)[0]
title = query(result, title_query)[0] title = query(result, title_query)[0]
content = query(result, content_query)[0] try:
content = query(result, content_query)[0]
except:
content = ""
results.append({'url': url, 'title': title, 'content': content}) results.append({'url': url, 'title': title, 'content': content})
else: else:
for url, title, content in zip( for url, title, content in zip(