diff options
author | Vojtěch Fošnár <v.fosnar@protonmail.com> | 2022-04-14 03:02:05 +0200 |
---|---|---|
committer | Vojtěch Fošnár <v.fosnar@protonmail.com> | 2022-04-14 03:02:05 +0200 |
commit | de4af2fefd70297ee961f05aa30d9b543927fc75 (patch) | |
tree | a08b56787d6e79512a572cd260fcd91c1f239df7 /searx/autocomplete.py | |
parent | 09230bfad9dea35a6ed112ea7096935d1c821bd9 (diff) | |
download | searxng-de4af2fefd70297ee961f05aa30d9b543927fc75.tar.gz searxng-de4af2fefd70297ee961f05aa30d9b543927fc75.zip |
[enh] add seznam autocomplete
Diffstat (limited to 'searx/autocomplete.py')
-rw-r--r-- | searx/autocomplete.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 8a67f8139..ff299d184 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -85,6 +85,22 @@ def google(query, lang): return results +def seznam(query, _lang): + # seznam search autocompleter + url = 'https://suggest.seznam.cz/fulltext/cs?{query}' + + resp = get(url.format(query=urlencode( + {'phrase': query, 'cursorPosition': len(query), 'format': 'json-2', 'highlight': '1', 'count': '6'} + ))) + + if not resp.ok: + return [] + + data = resp.json() + return [''.join( + [part.get('text', '') for part in item.get('text', [])] + ) for item in data.get('result', []) if item.get('itemType', None) == 'ItemType.TEXT'] + def startpage(query, lang): # startpage autocompleter lui = ENGINES_LANGUAGES['startpage'].get(lang, 'english') @@ -133,6 +149,7 @@ backends = { 'dbpedia': dbpedia, 'duckduckgo': duckduckgo, 'google': google, + 'seznam': seznam, 'startpage': startpage, 'swisscows': swisscows, 'qwant': qwant, |