From 77d07c87434ad6c562cf318cb05787cb527c6e3d Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 15 Sep 2026 17:48:27 +0200 Subject: [PATCH] [mod] yandex: simplify request method and drop unused params/cookies We previously set the 'cookie' cookie value with a timestamp from 2024 to `yq=...`. The cookie is not actually used in Yandex, instead we probably wanted to set the `yq` cookie instead. But since the engine works without it, it can be dropped. Also simplifies the request method a bit to be easier to read. --- searx/engines/yandex.py | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/searx/engines/yandex.py b/searx/engines/yandex.py index 817ac9624..76dedfac5 100644 --- a/searx/engines/yandex.py +++ b/searx/engines/yandex.py @@ -60,33 +60,28 @@ def catch_bad_response(resp: "SXNG_Response") -> None: def request(query: str, params: "OnlineParams") -> None: - query_params_web = { - "tmpl_version": "releases", + args: dict[str, t.Any] = { "text": query, - "web": "1", - "frame": "1", - "searchid": "3131712", } + if params['pageno'] > 1: + args["p"] = params["pageno"] - 1 - lang = params["language"].split("-")[0] # type: ignore - if lang in yandex_supported_langs: - query_params_web["lang"] = lang + if search_type == 'web': + lang = params["searxng_locale"].split("-")[0] + if lang in yandex_supported_langs: + args["lang"] = lang - query_params_images = { - "text": query, - "uinfo": "sw-1920-sh-1080-ww-1125-wh-999", - } - - if params["pageno"] > 1: - query_params_web["p"] = params["pageno"] - 1 # type: ignore - query_params_images["p"] = params["pageno"] - 1 # type: ignore - - params["cookies"] = {"cookie": "yp=1716337604.sp.family%3A0#1685406411.szm.1:1920x1080:1920x999"} - - if search_type == "web": - params["url"] = f"{base_url_web}?{urlencode(query_params_web)}" - elif search_type == "images": - params["url"] = f"{base_url_images}?{urlencode(query_params_images)}" + args.update( + { + "tmpl_version": "releases", + "web": "1", + "frame": "1", + "searchid": "3131712", + } + ) + params['url'] = f"{base_url_web}?{urlencode(args)}" + elif search_type == 'images': + params['url'] = f"{base_url_images}?{urlencode(args)}" def _parse_json_results(dom: html.HtmlElement) -> dict[str, t.Any]: