From a0037313ea1a3810aea50c6597c8a36eaebdd259 Mon Sep 17 00:00:00 2001 From: asciimoo Date: Wed, 16 Oct 2013 23:21:04 +0200 Subject: [PATCH] [mod] wikipedia limited to first result --- searx/engines/wikipedia.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py index fcd917abf..308295946 100644 --- a/searx/engines/wikipedia.py +++ b/searx/engines/wikipedia.py @@ -9,7 +9,8 @@ def request(query, params): def response(resp): search_results = loads(resp.text) results = [] - for res in search_results.get('query', {}).get('search', []): - results.append({'url': 'https://en.wikipedia.org/wiki/%s' % res['title'].replace(' ', '_'), 'title': res['title']}) + res = search_results.get('query', {}).get('search', []) + if len(res): + results.append({'url': 'https://en.wikipedia.org/wiki/%s' % res[0]['title'].replace(' ', '_'), 'title': res[0]['title']}) return results