SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] searchzee: bypass botblocking
Bnyroccffbfc1649e
diff --git a/searx/engines/searchzee.py b/searx/engines/searchzee.pyindex 00cc51fb5..7573005e8 100644--- a/searx/engines/searchzee.py+++ b/searx/engines/searchzee.py@@ -4,13 +4,11 @@ independent search infrastructure."""import typing as tfrom urllib.parse import urlencode+import uuid-from searx.exceptions import SearxEngineAPIExceptionfrom searx.extended_types import SXNG_Response-from searx.network import getfrom searx.result_types import EngineResults-from searx.utils import extr, html_to_text-from searx.enginelib import EngineCache+from searx.utils import html_to_textif t.TYPE_CHECKING:from searx.search.processors import OnlineParams@@ -34,43 +32,19 @@ SearchzeeCategType = t.Literal["web", "news"]searchzee_categ: SearchzeeCategType = None # type: ignore[reportAssignmentType]-CACHE: EngineCache-"""Cache for storing the scraped API Token."""-base_url = "https://searchzee.com"# only supports for newstime_range_map = {"day": "pd", "week": "pw", "month": "pm", "year": "py"}-def setup(engine_settings: dict[str, t.Any]) -> bool:+def setup(_: dict[str, t.Any]):if searchzee_categ not in t.get_args(SearchzeeCategType):raise ValueError("invalid category: %s" % searchzee_categ)- global CACHE # pylint: disable=global-statement- CACHE = EngineCache(engine_settings["name"]) # type: ignore[reportAny]- return True---def _obtain_api_token() -> str:- token: str | None = CACHE.get("token") # type: ignore[reportAny]- if token:- return token-- token_resp = get(- f"{base_url}/app.js",- )- if not token_resp.ok:- raise SearxEngineAPIException("failed to obtain api key")-- token = extr(token_resp.text, "const SEARCHZEE_API_TOKEN = \"", "\";")- CACHE.set("token", token, expire=3600)-- return token-def request(query: str, params: "OnlineParams"):- params["headers"]["X-SearchZee-Token"] = _obtain_api_token()+ params["cookies"]["szs"] = str(uuid.uuid4())args = {"q": query, "type": searchzee_categ, "offset": params["pageno"] - 1}if params["time_range"]: