From 8f452ee89293d9a752a776f4c33f5a5f124fff97 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 2 Sep 2026 16:29:33 +0200 Subject: [fix] chatnoir: fails to extract API session parameters --- searx/engines/chatnoir.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/searx/engines/chatnoir.py b/searx/engines/chatnoir.py index 3123d6c68..ef4a34e60 100644 --- a/searx/engines/chatnoir.py +++ b/searx/engines/chatnoir.py @@ -41,7 +41,7 @@ search_index = "cw22" `_ for a full list.""" -def _obtain_api_key() -> tuple[str, str, str]: +def _obtain_api_key() -> tuple[str, str]: home_resp = get(base_url) if not home_resp.ok: raise SearxEngineAPIException("failed to obtain api key") @@ -58,10 +58,9 @@ def _obtain_api_key() -> tuple[str, str, str]: ) if not token_resp.ok: raise SearxEngineAPIException("failed to obtain api key") - session_id = token_resp.cookies["sessionid"] scraped_api_key = token_resp.json()["token"]["token"] - return csrf_token, session_id, scraped_api_key + return csrf_token, scraped_api_key def request(query: str, params: "OnlineParams"): @@ -73,7 +72,7 @@ def request(query: str, params: "OnlineParams"): params["headers"].update(headers) else: - csrf_token, session_id, scraped_api_key = _obtain_api_key() + csrf_token, scraped_api_key = _obtain_api_key() headers = { "Authorization": f"Bearer {scraped_api_key}", @@ -81,7 +80,7 @@ def request(query: str, params: "OnlineParams"): } params["headers"].update(headers) - params["cookies"] = {"csrftoken": session_id, "sessionid": session_id} + params["cookies"] = {"csrftoken": csrf_token} params["url"] = f"{base_url}/api/v1/_search" params["method"] = "POST" -- cgit v1.2.3