diff --git a/docs/admin/settings/settings_search.rst b/docs/admin/settings/settings_search.rst index b60810d78..8bb4c8676 100644 --- a/docs/admin/settings/settings_search.rst +++ b/docs/admin/settings/settings_search.rst @@ -43,6 +43,7 @@ - ``google`` - ``mwmbl`` - ``naver`` + - ``privacywall`` - ``quark`` - ``qwant`` - ``seznam`` diff --git a/docs/dev/search_api.rst b/docs/dev/search_api.rst index 3e8779af6..7c7ccdb9c 100644 --- a/docs/dev/search_api.rst +++ b/docs/dev/search_api.rst @@ -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. diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 8b7285376..4e66dff22 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -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, diff --git a/searx/settings.yml b/searx/settings.yml index f9a342f20..c567af1c9 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -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