1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-22 12:10:11 +01:00

[mod] autocomplete.py: add support for mwmbl completions

This commit is contained in:
Bnyro 2023-08-23 15:24:42 +02:00 committed by Markus Heiser
parent 19300a5659
commit df71c24b20
4 changed files with 15 additions and 3 deletions

View File

@ -35,6 +35,7 @@
- ``dbpedia`` - ``dbpedia``
- ``duckduckgo`` - ``duckduckgo``
- ``google`` - ``google``
- ``mwmbl``
- ``startpage`` - ``startpage``
- ``swisscows`` - ``swisscows``
- ``qwant`` - ``qwant``

View File

@ -68,8 +68,8 @@ Parameters
Proxy image results through SearXNG. Proxy image results through SearXNG.
``autocomplete`` : default from :ref:`settings search` ``autocomplete`` : default from :ref:`settings search`
[ ``google``, ``dbpedia``, ``duckduckgo``, ``startpage``, ``wikipedia``, [ ``google``, ``dbpedia``, ``duckduckgo``, ``mwmbl``, ``startpage``,
``swisscows``, ``qwant`` ] ``wikipedia``, ``swisscows``, ``qwant`` ]
Service which completes words as you type. Service which completes words as you type.

View File

@ -110,6 +110,16 @@ def google_complete(query, sxng_locale):
return results return results
def mwmbl(query, _lang):
# mwmbl autocompleter
url = 'https://api.mwmbl.org/search/complete?{query}'
results = get(url.format(query=urlencode({'q': query}))).json()[1]
# results starting with `go:` are direct urls and not useful for auto completion
return [result for result in results if not result.startswith("go: ") and not result.startswith("search: ")]
def seznam(query, _lang): def seznam(query, _lang):
# seznam search autocompleter # seznam search autocompleter
url = 'https://suggest.seznam.cz/fulltext/cs?{query}' url = 'https://suggest.seznam.cz/fulltext/cs?{query}'
@ -208,6 +218,7 @@ backends = {
'dbpedia': dbpedia, 'dbpedia': dbpedia,
'duckduckgo': duckduckgo, 'duckduckgo': duckduckgo,
'google': google_complete, 'google': google_complete,
'mwmbl': mwmbl,
'seznam': seznam, 'seznam': seznam,
'startpage': startpage, 'startpage': startpage,
'swisscows': swisscows, 'swisscows': swisscows,

View File

@ -23,7 +23,7 @@ brand:
search: search:
# Filter results. 0: None, 1: Moderate, 2: Strict # Filter results. 0: None, 1: Moderate, 2: Strict
safe_search: 0 safe_search: 0
# Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "yandex", # Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "yandex", "mwmbl",
# "seznam", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off # "seznam", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
# by default. # by default.
autocomplete: "" autocomplete: ""