diff options
| author | Bnyro <bnyro@tutanota.com> | 2026-09-03 15:50:26 +0200 |
|---|---|---|
| committer | Bnyro <bnyro@tutanota.com> | 2026-09-04 09:49:07 +0200 |
| commit | 15b0c8ef3ab02a86131040e5eabc0d5b82bb9470 (patch) | |
| tree | e8b3af5cece7766028c0c15a001da8d1effc81e1 | |
| parent | a1144dda3e97668c9d445022b7019c224cd4bb1e (diff) | |
[feat] engines: add JS-based s1search engine
| -rw-r--r-- | searx/engines/s1search_rampjs.py | 63 | ||||
| -rw-r--r-- | searx/settings.yml | 14 |
2 files changed, 70 insertions, 7 deletions
diff --git a/searx/engines/s1search_rampjs.py b/searx/engines/s1search_rampjs.py new file mode 100644 index 000000000..10478f2c0 --- /dev/null +++ b/searx/engines/s1search_rampjs.py @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""JavaScript-based s1search implementation. See :ref:`s1search engine`. + +Works for all s1search sites that contain the ``__RAMPJS__`` JavaScript variable. +""" + +import json +import typing as t +from urllib.parse import urlencode + +from searx.result_types import EngineResults +from searx.utils import extr, html_to_text + +if t.TYPE_CHECKING: + from searx.search.processors import OnlineParams + from searx.extended_types import SXNG_Response + +about = { + "website": "https://s1search.co", + "official_api_documentation": None, + "use_official_api": False, + "require_api_key": False, + "results": "JSON", +} + +categories = ["general"] +paging = True + +base_url = "https://search.answers.com" +# other working base URLs: +# - https://search.nation.online +# - https://search.activebeat.com +# - https://search.legalboulevard.com +# - https://search.walletgenius.com +# - https://search.legalboulevard.com + + +def request(query: str, params: "OnlineParams"): + args = {"q": query, "page": params["pageno"]} + params["url"] = f"{base_url}/?{urlencode(args)}" + + +def response(resp: "SXNG_Response") -> EngineResults: + res = EngineResults() + + data_raw = extr(resp.text, "response: ", " };") + data = json.loads(data_raw) + + mainline = [s for s in data["search"]["regions"] if s["name"] == "mainline"][0] + for group in mainline["groups"]: + for result in group["results"]: + if not ("url" in result or "clickUrl" in result): + continue + + res.add( + res.types.MainResult( + url=result.get("url") or result.get("clickUrl"), + title=html_to_text(result["title"]), + content=html_to_text(result["description"]), + ) + ) + + return res diff --git a/searx/settings.yml b/searx/settings.yml index 0b5e59f11..4d370e575 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -3307,13 +3307,6 @@ engines: website: https://minecraft.wiki/ wikidata_id: Q105533483 - # s1search google engines / mirrors - - name: searchtoday - engine: s1search - shortcut: std - base_url: https://info.searchtoday.site - disabled: true - - name: sina engine: json_engine shortcut: sina @@ -3359,6 +3352,13 @@ engines: disabled: true inactive: true + # s1search engines / mirrors with rampjs page layout + - name: s1search + engine: s1search_rampjs + shortcut: s1 + disabled: true + inactive: true + # Doku engine lets you access to any Doku wiki instance: # A public one or a privete/corporate one. # - name: ubuntuwiki |
