diff options
author | Adam Tauber <asciimoo@gmail.com> | 2017-11-02 00:43:29 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2017-11-02 00:43:29 +0100 |
commit | 181f1c630534d004815687222b737fdab76371c7 (patch) | |
tree | 700c3e51ef03c777c3ca93ed5bf4bce73b997b3d | |
parent | ddeea6386b0ff6c837925513af27d383513dae19 (diff) | |
download | searxng-181f1c630534d004815687222b737fdab76371c7.tar.gz searxng-181f1c630534d004815687222b737fdab76371c7.zip |
[mod] add more error handling to json engine
-rw-r--r-- | searx/engines/json_engine.py | 10 |
1 files 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( |