Browse Source

[mod] wikipedia limited to first result

asciimoo 11 years ago
parent
commit
a0037313ea
1 changed files with 3 additions and 2 deletions
  1. 3 2
      searx/engines/wikipedia.py

+ 3 - 2
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