mirror of
https://github.com/searxng/searxng.git
synced 2026-05-07 18:03:51 +02:00
[mod] engines: remove stract engine (#5800)
Engine probably dead, developer doesn't have time to maintain it anymore: - https://github.com/StractOrg/stract/issues/267 Related: - https://github.com/searxng/searxng/pull/3099
This commit is contained in:
@@ -47,7 +47,6 @@
|
|||||||
- ``seznam``
|
- ``seznam``
|
||||||
- ``sogou``
|
- ``sogou``
|
||||||
- ``startpage``
|
- ``startpage``
|
||||||
- ``stract``
|
|
||||||
- ``swisscows``
|
- ``swisscows``
|
||||||
- ``wikipedia``
|
- ``wikipedia``
|
||||||
- ``yandex``
|
- ``yandex``
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ Parameters
|
|||||||
|
|
||||||
``autocomplete`` : default from :ref:`settings search`
|
``autocomplete`` : default from :ref:`settings search`
|
||||||
[ ``google``, ``dbpedia``, ``duckduckgo``, ``mwmbl``, ``startpage``,
|
[ ``google``, ``dbpedia``, ``duckduckgo``, ``mwmbl``, ``startpage``,
|
||||||
``wikipedia``, ``stract``, ``swisscows``, ``qwant`` ]
|
``wikipedia``, ``swisscows``, ``qwant`` ]
|
||||||
|
|
||||||
Service which completes words as you type.
|
Service which completes words as you type.
|
||||||
|
|
||||||
|
|||||||
+2
-16
@@ -3,9 +3,8 @@
|
|||||||
# pylint: disable=use-dict-literal
|
# pylint: disable=use-dict-literal
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import html
|
|
||||||
import typing as t
|
import typing as t
|
||||||
from urllib.parse import urlencode, quote_plus
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
import lxml.etree
|
import lxml.etree
|
||||||
import lxml.html
|
import lxml.html
|
||||||
@@ -16,7 +15,7 @@ from searx.engines import (
|
|||||||
engines,
|
engines,
|
||||||
google,
|
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.exceptions import SearxEngineResponseException
|
||||||
from searx.utils import extr, gen_useragent
|
from searx.utils import extr, gen_useragent
|
||||||
|
|
||||||
@@ -268,18 +267,6 @@ def startpage(query: str, sxng_locale: str) -> list[str]:
|
|||||||
return results
|
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]:
|
def swisscows(query: str, _sxng_locale: str) -> list[str]:
|
||||||
# swisscows autocompleter
|
# swisscows autocompleter
|
||||||
url = 'https://swisscows.ch/api/suggest?{query}&itemsCount=5'
|
url = 'https://swisscows.ch/api/suggest?{query}&itemsCount=5'
|
||||||
@@ -355,7 +342,6 @@ backends: dict[str, t.Callable[[str, str], list[str]]] = {
|
|||||||
'seznam': seznam,
|
'seznam': seznam,
|
||||||
'sogou': sogou,
|
'sogou': sogou,
|
||||||
'startpage': startpage,
|
'startpage': startpage,
|
||||||
'stract': stract,
|
|
||||||
'swisscows': swisscows,
|
'swisscows': swisscows,
|
||||||
'wikipedia': wikipedia,
|
'wikipedia': wikipedia,
|
||||||
'yandex': yandex,
|
'yandex': yandex,
|
||||||
|
|||||||
@@ -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
|
|
||||||
+1
-6
@@ -33,7 +33,7 @@ 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: "360search", "baidu", "brave", "dbpedia", "duckduckgo", "google", "yandex",
|
# 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.
|
# leave blank to turn it off by default.
|
||||||
autocomplete: ""
|
autocomplete: ""
|
||||||
# minimun characters to type before autocompleter starts
|
# minimun characters to type before autocompleter starts
|
||||||
@@ -2498,11 +2498,6 @@ engines:
|
|||||||
results: HTML
|
results: HTML
|
||||||
language: de
|
language: de
|
||||||
|
|
||||||
- name: stract
|
|
||||||
engine: stract
|
|
||||||
shortcut: str
|
|
||||||
disabled: true
|
|
||||||
|
|
||||||
- name: svgrepo
|
- name: svgrepo
|
||||||
engine: svgrepo
|
engine: svgrepo
|
||||||
shortcut: svg
|
shortcut: svg
|
||||||
|
|||||||
Reference in New Issue
Block a user