mirror of
https://github.com/searxng/searxng.git
synced 2026-09-23 06:36:12 +00:00
[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.
This commit is contained in:
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user