Browse Source

[fix] wikipedia autocomplete error handling

Adam Tauber 11 years ago
parent
commit
d2f89f0446
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      searx/autocomplete.py

+ 3
- 1
searx/autocomplete.py View File

42
     url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json'  # noqa
42
     url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json'  # noqa
43
 
43
 
44
     resp = loads(get(url.format(urlencode(dict(q=query)))).text)
44
     resp = loads(get(url.format(urlencode(dict(q=query)))).text)
45
-    return resp[1]
45
+    if len(resp) > 1:
46
+        return resp[1]
47
+    return []
46
 
48
 
47
 
49
 
48
 backends = {'dbpedia': dbpedia,
50
 backends = {'dbpedia': dbpedia,