mirror of
https://github.com/searxng/searxng.git
synced 2025-07-13 00:09:18 +02:00
[mod] qwant: fetch engine traits (data_type: traits_v1)
Implements a fetch_traits function for the Qwant engines. .. note:: Includes migration of the request methode from 'supported_languages' to 'traits' (EngineTraits) object! Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
fc0c775030
commit
c1ae2ef57c
3 changed files with 45 additions and 46 deletions
|
@ -126,16 +126,16 @@ def swisscows(query, _lang):
|
|||
return resp
|
||||
|
||||
|
||||
def qwant(query, lang):
|
||||
# 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, 'lang': lang})))
|
||||
|
||||
def qwant(query, sxng_locale):
|
||||
"""Autocomplete from Qwant. Supports Qwant's regions."""
|
||||
results = []
|
||||
|
||||
locale = engines['qwant'].traits.get_region(sxng_locale, 'en_US')
|
||||
url = 'https://api.qwant.com/v3/suggest?{query}'
|
||||
resp = get(url.format(query=urlencode({'q': query, 'locale': locale, 'version': '2'})))
|
||||
|
||||
if resp.ok:
|
||||
data = loads(resp.text)
|
||||
data = resp.json()
|
||||
if data['status'] == 'success':
|
||||
for item in data['data']['items']:
|
||||
results.append(item['value'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue