From 6b6cbdae20f298fc4761798dbbccdddd858af515 Mon Sep 17 00:00:00 2001 From: neodarz Date: Fri, 18 Jan 2019 20:38:00 +0100 Subject: Fix error when result not found --- src/khanindexer.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/khanindexer.py b/src/khanindexer.py index dc020de..abfce3f 100644 --- a/src/khanindexer.py +++ b/src/khanindexer.py @@ -36,12 +36,15 @@ def response(resp): datas = json.loads(resp.text) - for el in datas: - results.append({ - 'title': el['title'], - 'content': el['excerpts'][0], - 'url': el['url'] - }) + if not 'error' in datas: + for el in datas: + results.append({ + 'title': el['title'], + 'content': el['excerpts'][0], + 'url': el['url'] + }) + else: + print("ERROR:Search server: "+str(datas['msg'])) # return results return results -- cgit v1.2.1