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] engine mullvadleta - ignore HTTP 403 & 429 response
Markus Heisere840e3f96025
diff --git a/searx/engines/mullvad_leta.py b/searx/engines/mullvad_leta.pyindex 0ad549b35..f494e812d 100644--- a/searx/engines/mullvad_leta.py+++ b/searx/engines/mullvad_leta.py@@ -43,9 +43,12 @@ import babelfrom httpx import Responsefrom lxml import htmlfrom searx.enginelib.traits import EngineTraits+from searx.extended_types import SXNG_Response+from searx.locales import get_official_locales, language_tag, region_tagfrom searx.utils import eval_xpath_listfrom searx.result_types import EngineResults, MainResult+from searx.network import raise_for_httperrorsearch_url = "https://leta.mullvad.net"@@ -112,7 +115,8 @@ class DataNodeResultIndices(t.TypedDict):favicon: int-def request(query: str, params: dict):+def request(query: str, params: dict[str, t.Any]) -> None:+ params["raise_for_httperror"] = Falseparams["method"] = "GET"args = {"q": query,@@ -136,10 +140,19 @@ def request(query: str, params: dict):params["url"] = f"{search_url}/search/__data.json?{urlencode(args)}"- return params+def response(resp: SXNG_Response) -> EngineResults:+ results = EngineResults()++ if resp.status_code in (403, 429):+ # It doesn't matter if you're using Mullvad's VPN and a proper browser,+ # you'll still get blocked for specific searches with a 403 or 429 HTTP+ # status code.+ # https://github.com/searxng/searxng/issues/5328#issue-3518337233+ return results+ # raise for other errors+ raise_for_httperror(resp)-def response(resp: Response) -> EngineResults:json_response = resp.json()nodes = json_response["nodes"]@@ -159,7 +172,6 @@ def response(resp: Response) -> EngineResults:query_items_indices = query_meta_data["items"]- results = EngineResults()for idx in data_nodes[query_items_indices]:query_item_indices: DataNodeResultIndices = data_nodes[idx]results.add(