mirror of
https://github.com/searxng/searxng.git
synced 2024-11-23 19:31:00 +00:00
Merge pull request #515 from dalf/qwant
[enh] autocompletion : add qwant
This commit is contained in:
commit
474e574066
1 changed files with 18 additions and 0 deletions
|
@ -161,6 +161,23 @@ def startpage(query):
|
||||||
return []
|
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):
|
def wikipedia(query):
|
||||||
# wikipedia autocompleter
|
# wikipedia autocompleter
|
||||||
url = 'https://en.wikipedia.org/w/api.php?action=opensearch&{0}&limit=10&namespace=0&format=json'
|
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,
|
'duckduckgo': duckduckgo,
|
||||||
'google': google,
|
'google': google,
|
||||||
'startpage': startpage,
|
'startpage': startpage,
|
||||||
|
'qwant': qwant,
|
||||||
'wikipedia': wikipedia
|
'wikipedia': wikipedia
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue