forked from zaclys/searxng
Merge pull request #499 from dalf/fix-autocompletion-startpage
[fix] startpage autocompletion
This commit is contained in:
commit
de7f8b757b
|
@ -24,6 +24,7 @@ from httpx import HTTPError
|
||||||
|
|
||||||
|
|
||||||
from searx import settings
|
from searx import settings
|
||||||
|
from searx.data import ENGINES_LANGUAGES
|
||||||
from searx.network import get as http_get
|
from searx.network import get as http_get
|
||||||
from searx.exceptions import SearxEngineResponseException
|
from searx.exceptions import SearxEngineResponseException
|
||||||
|
|
||||||
|
@ -77,12 +78,11 @@ def google(query, lang):
|
||||||
|
|
||||||
def startpage(query, lang):
|
def startpage(query, lang):
|
||||||
# startpage autocompleter
|
# startpage autocompleter
|
||||||
url = 'https://startpage.com/do/suggest?{query}'
|
lui = ENGINES_LANGUAGES['startpage'].get(lang, 'english')
|
||||||
|
url = 'https://startpage.com/suggestions?{query}'
|
||||||
resp = get(url.format(query=urlencode({'query': query}))).text.split('\n')
|
resp = get(url.format(query=urlencode({'q': query, 'segment': 'startpage.udog', 'lui': lui})))
|
||||||
if len(resp) > 1:
|
data = resp.json()
|
||||||
return resp
|
return [e['text'] for e in data.get('suggestions', []) if 'text' in e]
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
def swisscows(query, lang):
|
def swisscows(query, lang):
|
||||||
|
|
Loading…
Reference in New Issue