logo

searx

My custom branche(s) on searx, a meta-search engine
commit: 181f1c630534d004815687222b737fdab76371c7
parent: ddeea6386b0ff6c837925513af27d383513dae19
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Thu,  2 Nov 2017 00:43:29 +0100

[mod] add more error handling to json engine

Diffstat:

Msearx/engines/json_engine.py10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git 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(