mirror of
https://github.com/searxng/searxng.git
synced 2026-06-13 21:37:51 +02:00
[feat] autocomplete: add privacywall autocompleter (#6211)
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
- ``google``
|
||||
- ``mwmbl``
|
||||
- ``naver``
|
||||
- ``privacywall``
|
||||
- ``quark``
|
||||
- ``qwant``
|
||||
- ``seznam``
|
||||
|
||||
@@ -87,7 +87,7 @@ Parameters
|
||||
|
||||
``autocomplete`` : default from :ref:`settings search`
|
||||
[ ``google``, ``dbpedia``, ``duckduckgo``, ``mwmbl``, ``startpage``,
|
||||
``wikipedia``, ``swisscows``, ``qwant`` ]
|
||||
``privacywall``, ``wikipedia``, ``swisscows``, ``qwant`` ]
|
||||
|
||||
Service which completes words as you type.
|
||||
|
||||
|
||||
@@ -179,6 +179,23 @@ def naver(query: str, _sxng_locale: str) -> list[str]:
|
||||
return results
|
||||
|
||||
|
||||
def privacywall(query: str, sxng_locale: str) -> list[str]:
|
||||
# Privacywall search autocompleter
|
||||
country = None
|
||||
if "-" in sxng_locale:
|
||||
country = sxng_locale.split("-")[1]
|
||||
args = {'q': query, 'cc': country}
|
||||
|
||||
url = f"https://www.privacywall.org/search/secure/suggestions.php?{urlencode(args)}"
|
||||
response = get(url)
|
||||
|
||||
if not response.ok:
|
||||
return []
|
||||
|
||||
data: list[list[str]] = response.json()
|
||||
return data[1]
|
||||
|
||||
|
||||
def qihu360search(query: str, _sxng_locale: str) -> list[str]:
|
||||
# 360Search search autocompleter
|
||||
url = f"https://sug.so.360.cn/suggest?{urlencode({'format': 'json', 'word': query})}"
|
||||
@@ -361,6 +378,7 @@ backends: dict[str, t.Callable[[str, str], list[str]]] = {
|
||||
'google': google_complete,
|
||||
'mwmbl': mwmbl,
|
||||
'naver': naver,
|
||||
'privacywall': privacywall,
|
||||
'quark': quark,
|
||||
'qwant': qwant,
|
||||
'seznam': seznam,
|
||||
|
||||
+2
-2
@@ -41,8 +41,8 @@ search:
|
||||
# Filter results. 0: None, 1: Moderate, 2: Strict
|
||||
safe_search: 0
|
||||
# Existing autocomplete backends: "360search", "baidu", "bing", "brave", "dbpedia", "duckduckgo", "google",
|
||||
# "yandex", "mwmbl", "naver", "seznam", "sogou", "startpage", "swisscows", "quark", "qwant", "wikipedia" -
|
||||
# leave blank to turn it off by default.
|
||||
# "yandex", "privacywall", "mwmbl", "naver", "seznam", "sogou", "startpage", "swisscows", "quark", "qwant",
|
||||
# "wikipedia" - leave blank to turn it off by default.
|
||||
autocomplete: ""
|
||||
# minimun characters to type before autocompleter starts
|
||||
autocomplete_min: 4
|
||||
|
||||
Reference in New Issue
Block a user