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:
|
def request(query: str, params: "OnlineParams") -> None:
|
||||||
query_params_web = {
|
args: dict[str, t.Any] = {
|
||||||
"tmpl_version": "releases",
|
|
||||||
"text": query,
|
"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 search_type == 'web':
|
||||||
if lang in yandex_supported_langs:
|
lang = params["searxng_locale"].split("-")[0]
|
||||||
query_params_web["lang"] = lang
|
if lang in yandex_supported_langs:
|
||||||
|
args["lang"] = lang
|
||||||
|
|
||||||
query_params_images = {
|
args.update(
|
||||||
"text": query,
|
{
|
||||||
"uinfo": "sw-1920-sh-1080-ww-1125-wh-999",
|
"tmpl_version": "releases",
|
||||||
}
|
"web": "1",
|
||||||
|
"frame": "1",
|
||||||
if params["pageno"] > 1:
|
"searchid": "3131712",
|
||||||
query_params_web["p"] = params["pageno"] - 1 # type: ignore
|
}
|
||||||
query_params_images["p"] = params["pageno"] - 1 # type: ignore
|
)
|
||||||
|
params['url'] = f"{base_url_web}?{urlencode(args)}"
|
||||||
params["cookies"] = {"cookie": "yp=1716337604.sp.family%3A0#1685406411.szm.1:1920x1080:1920x999"}
|
elif search_type == 'images':
|
||||||
|
params['url'] = f"{base_url_images}?{urlencode(args)}"
|
||||||
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)}"
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_json_results(dom: html.HtmlElement) -> dict[str, t.Any]:
|
def _parse_json_results(dom: html.HtmlElement) -> dict[str, t.Any]:
|
||||||
|
|||||||
Reference in New Issue
Block a user