From 181f1c630534d004815687222b737fdab76371c7 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Thu, 2 Nov 2017 00:43:29 +0100 Subject: [PATCH] [mod] add more error handling to json engine --- searx/engines/json_engine.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/searx/engines/json_engine.py b/searx/engines/json_engine.py index 67d6a5a65..fa169f015 100644 --- a/searx/engines/json_engine.py +++ b/searx/engines/json_engine.py @@ -98,10 +98,16 @@ def response(resp): results = [] json = loads(resp.text) 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] 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}) else: for url, title, content in zip(