diff options
author | Alexandre Flament <alex@al-f.net> | 2021-11-13 13:26:47 +0100 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-11-13 13:26:47 +0100 |
commit | 3c3599c9e60d68bca1b2f5d26b9f4cf070606976 (patch) | |
tree | c721edc62e22228dfe0bc2f9dc8b920e4e918e82 /searx/autocomplete.py | |
parent | e839910f4c4b085463f1522b4191448935468b53 (diff) | |
download | searxng-3c3599c9e60d68bca1b2f5d26b9f4cf070606976.tar.gz searxng-3c3599c9e60d68bca1b2f5d26b9f4cf070606976.zip |
[fix] startpage autocompletion
Diffstat (limited to 'searx/autocomplete.py')
-rw-r--r-- | searx/autocomplete.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index cf2deb62f..a55377cd9 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -24,6 +24,7 @@ from httpx import HTTPError from searx import settings +from searx.data import ENGINES_LANGUAGES from searx.network import get as http_get from searx.exceptions import SearxEngineResponseException @@ -77,12 +78,11 @@ def google(query, lang): def startpage(query, lang): # startpage autocompleter - url = 'https://startpage.com/do/suggest?{query}' - - resp = get(url.format(query=urlencode({'query': query}))).text.split('\n') - if len(resp) > 1: - return resp - return [] + lui = ENGINES_LANGUAGES['startpage'].get(lang, 'english') + url = 'https://startpage.com/suggestions?{query}' + resp = get(url.format(query=urlencode({'q': query, 'segment': 'startpage.udog', 'lui': lui}))) + data = resp.json() + return [e['text'] for e in data.get('suggestions', []) if 'text' in e] def swisscows(query, lang): |