diff options
-rw-r--r-- | src/khanindexer.py | 15 |
1 files changed, 9 insertions, 6 deletions
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 |