summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2022-04-15 17:50:32 +0200
committerGitHub <noreply@github.com>2022-04-15 17:50:32 +0200
commitab9a4b732815cce32a442ca474d83e4f34f36a1e (patch)
tree34e57a7fe9f96db75d4bdb381e03267d8a9fb27d /searx
parentab522b438873b509403ebaf1121172b6c9102960 (diff)
parentccd8305465200a23db37f3e1fdaf85ff39608b76 (diff)
downloadsearxng-ab9a4b732815cce32a442ca474d83e4f34f36a1e.tar.gz
searxng-ab9a4b732815cce32a442ca474d83e4f34f36a1e.zip
Merge pull request #1090 from vfosnar/master
[enh] add seznam autocomplete
Diffstat (limited to 'searx')
-rw-r--r--searx/autocomplete.py17
-rw-r--r--searx/settings.yml2
2 files changed, 18 insertions, 1 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,
diff --git a/searx/settings.yml b/searx/settings.yml
index eee0e1d7d..d6a465faf 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -15,7 +15,7 @@ search:
# Filter results. 0: None, 1: Moderate, 2: Strict
safe_search: 0
# Existing autocomplete backends: "dbpedia", "duckduckgo", "google",
- # "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
+ # "seznam", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
# by default.
autocomplete: ""
# Default search language - leave blank to detect from browser information or