summaryrefslogtreecommitdiff
path: root/searx/engines/wikipedia.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-10-16 23:21:04 +0200
committerasciimoo <asciimoo@gmail.com>2013-10-16 23:21:04 +0200
commita0037313ea1a3810aea50c6597c8a36eaebdd259 (patch)
tree0f6d381e374d2aaae886c50057ad625344865885 /searx/engines/wikipedia.py
parentd7f383d7ea11d94de170e8824934c10242a5580c (diff)
downloadsearxng-a0037313ea1a3810aea50c6597c8a36eaebdd259.tar.gz
searxng-a0037313ea1a3810aea50c6597c8a36eaebdd259.zip
[mod] wikipedia limited to first result
Diffstat (limited to 'searx/engines/wikipedia.py')
-rw-r--r--searx/engines/wikipedia.py5
1 files 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