diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-10-03 22:42:58 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2023-03-24 10:37:42 +0100 |
commit | c1ae2ef57c8a7da5df1f0fdacc0e6e745721b2ae (patch) | |
tree | 1e4137cf8fe42e2808b376376bcb143e47aa1dac /searx/autocomplete.py | |
parent | fc0c7750301b3475631ddd34a031451e068235b0 (diff) | |
download | searxng-c1ae2ef57c8a7da5df1f0fdacc0e6e745721b2ae.tar.gz searxng-c1ae2ef57c8a7da5df1f0fdacc0e6e745721b2ae.zip |
[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>
Diffstat (limited to 'searx/autocomplete.py')
-rw-r--r-- | searx/autocomplete.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 9b8755218..848600e57 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -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']) |