diff options
author | Alexandre Flament <alex@al-f.net> | 2016-03-02 19:54:06 +0800 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2016-03-02 19:54:06 +0800 |
commit | 6ab91515df3f85744f840216569a8ba6c5d71843 (patch) | |
tree | ce8790fe7cd8f2114453adcc955d38bc0193394b /searx/autocomplete.py | |
parent | bc81eda64bccbdb24c5f482563cac7ba88ef1027 (diff) | |
download | searxng-6ab91515df3f85744f840216569a8ba6c5d71843.tar.gz searxng-6ab91515df3f85744f840216569a8ba6c5d71843.zip |
[enh] autocompletion : add qwant
Diffstat (limited to 'searx/autocomplete.py')
-rw-r--r-- | searx/autocomplete.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index d92dc4246..94913e8d8 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -161,6 +161,23 @@ def startpage(query): return [] +def qwant(query): + # qwant autocompleter (additional parameter : lang=en_en&count=xxx ) + url = 'https://api.qwant.com/api/suggest?{query}' + + resp = get(url.format(query=urlencode({'q': query}))) + + results = [] + + if resp.ok: + data = loads(resp.text) + if data['status'] == 'success': + for item in data['data']['items']: + results.append(item['value']) + + return results + + def wikipedia(query): # wikipedia autocompleter url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json' @@ -175,5 +192,6 @@ backends = {'dbpedia': dbpedia, 'duckduckgo': duckduckgo, 'google': google, 'startpage': startpage, + 'qwant': qwant, 'wikipedia': wikipedia } |