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] xprivo: crashes when parsing response
Bnyro22c64b8d394b
diff --git a/searx/engines/xprivo.py b/searx/engines/xprivo.pyindex 8abb4474a..5463accd6 100644--- a/searx/engines/xprivo.py+++ b/searx/engines/xprivo.py@@ -4,6 +4,7 @@import jsonimport typing as t+from searx.exceptions import SearxEngineAPIExceptionfrom searx.result_types import EngineResultsif t.TYPE_CHECKING:@@ -58,8 +59,15 @@ def response(resp: "SXNG_Response") -> EngineResults:res = EngineResults()# response is a Server-Side Events (SSE) stream- data_raw = resp.text.split("\n", 1)[0].removeprefix("data: ")- data = json.loads(data_raw)+ # we search for a JSON object with the "results" key+ data_parts = [line for line in resp.text.split("\n") if line]+ for data_raw in data_parts:+ data_raw = data_raw.removeprefix("data: ")+ data: dict[str, t.Any] = json.loads(data_raw)+ if "results" in data:+ break+ else:+ raise SearxEngineAPIException("no results in response")result: dict[str, str]for result in data["results"]: