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]: