diff --git a/docs/admin/settings/settings_search.rst b/docs/admin/settings/settings_search.rst index 40c2607ad..b4ee39086 100644 --- a/docs/admin/settings/settings_search.rst +++ b/docs/admin/settings/settings_search.rst @@ -47,7 +47,6 @@ - ``seznam`` - ``sogou`` - ``startpage`` - - ``stract`` - ``swisscows`` - ``wikipedia`` - ``yandex`` diff --git a/docs/dev/search_api.rst b/docs/dev/search_api.rst index 016bd2e29..3e8779af6 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``, ``stract``, ``swisscows``, ``qwant`` ] + ``wikipedia``, ``swisscows``, ``qwant`` ] Service which completes words as you type. diff --git a/searx/autocomplete.py b/searx/autocomplete.py index fabd8be24..9612c85e8 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -3,9 +3,8 @@ # pylint: disable=use-dict-literal import json -import html import typing as t -from urllib.parse import urlencode, quote_plus +from urllib.parse import urlencode import lxml.etree import lxml.html @@ -16,7 +15,7 @@ from searx.engines import ( engines, google, ) -from searx.network import get as http_get, post as http_post # pyright: ignore[reportUnknownVariableType] +from searx.network import get as http_get, post as http_post from searx.exceptions import SearxEngineResponseException from searx.utils import extr, gen_useragent @@ -268,18 +267,6 @@ def startpage(query: str, sxng_locale: str) -> list[str]: return results -def stract(query: str, _sxng_locale: str) -> list[str]: - # stract autocompleter (beta) - url = f"https://stract.com/beta/api/autosuggest?q={quote_plus(query)}" - resp = post(url) - results: list[str] = [] - - if resp.ok: - results = [html.unescape(suggestion['raw']) for suggestion in resp.json()] - - return results - - def swisscows(query: str, _sxng_locale: str) -> list[str]: # swisscows autocompleter url = 'https://swisscows.ch/api/suggest?{query}&itemsCount=5' @@ -355,7 +342,6 @@ backends: dict[str, t.Callable[[str, str], list[str]]] = { 'seznam': seznam, 'sogou': sogou, 'startpage': startpage, - 'stract': stract, 'swisscows': swisscows, 'wikipedia': wikipedia, 'yandex': yandex, diff --git a/searx/engines/stract.py b/searx/engines/stract.py deleted file mode 100644 index 2c14bcc44..000000000 --- a/searx/engines/stract.py +++ /dev/null @@ -1,79 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -"""Stract is an independent open source search engine. At this state, it's -still in beta and hence this implementation will need to be updated once beta -ends. - -""" - -from json import dumps -from searx.utils import searxng_useragent -from searx.enginelib.traits import EngineTraits - -about = { - "website": "https://stract.com/", - "use_official_api": True, - "official_api_documentation": "https://stract.com/beta/api/docs/#/search/api", - "require_api_key": False, - "results": "JSON", -} -categories = ['general'] -paging = True - -base_url = "https://stract.com/beta/api" -search_url = base_url + "/search" - - -def request(query, params): - params['url'] = search_url - params['method'] = "POST" - params['headers'] = { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'User-Agent': searxng_useragent(), - } - region = traits.get_region(params["searxng_locale"], default=traits.all_locale) - params['data'] = dumps( - { - 'query': query, - 'page': params['pageno'] - 1, - 'selectedRegion': region, - } - ) - - return params - - -def response(resp): - results = [] - - for result in resp.json()["webpages"]: - results.append( - { - 'url': result['url'], - 'title': result['title'], - 'content': ''.join(fragment['text'] for fragment in result['snippet']['text']['fragments']), - } - ) - - return results - - -def fetch_traits(engine_traits: EngineTraits): - # pylint: disable=import-outside-toplevel - from searx import network - from babel import Locale, languages - from searx.locales import region_tag - - territories = Locale("en").territories - - json = network.get(base_url + "/docs/openapi.json").json() - regions = json['components']['schemas']['Region']['enum'] - - engine_traits.all_locale = regions[0] - - for region in regions[1:]: - for code, name in territories.items(): - if region not in (code, name): - continue - for lang in languages.get_official_languages(code, de_facto=True): - engine_traits.regions[region_tag(Locale(lang, code))] = region diff --git a/searx/settings.yml b/searx/settings.yml index d37b3b43b..f7d4e2c18 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -33,7 +33,7 @@ search: # Filter results. 0: None, 1: Moderate, 2: Strict safe_search: 0 # Existing autocomplete backends: "360search", "baidu", "brave", "dbpedia", "duckduckgo", "google", "yandex", - # "mwmbl", "naver", "seznam", "sogou", "startpage", "stract", "swisscows", "quark", "qwant", "wikipedia" - + # "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 @@ -2498,11 +2498,6 @@ engines: results: HTML language: de - - name: stract - engine: stract - shortcut: str - disabled: true - - name: svgrepo engine: svgrepo shortcut: svg