mirror of
https://github.com/searxng/searxng.git
synced 2026-05-28 05:40:12 +02:00
[fix] bing engines - geoblocking in China (#6134)
In regions like China, the domain must be adjusted to avoid a redirect. - https://github.com/searxng/searxng/issues/5243 - https://github.com/searxng/searxng/pull/5324 - https://github.com/searxng/searxng/pull/6133 Suggested / tested by @hubutui in https://github.com/searxng/searxng/pull/6133#issuecomment-4534637069 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
@@ -47,7 +47,7 @@ _safesearch_map: dict[int, str] = {
|
||||
}
|
||||
"""Filter results. 0: None, 1: Moderate, 2: Strict"""
|
||||
|
||||
base_url = "https://www.bing.com/search"
|
||||
base_url = "https://www.bing.com"
|
||||
"""Bing-Web search URL"""
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ def override_accept_language(params: "OnlineParams", engine_region: str | None)
|
||||
params["headers"]["Accept-Language"] = f"{engine_region},{lang};q=0.9"
|
||||
|
||||
|
||||
def request(query: str, params: "OnlineParams") -> "OnlineParams":
|
||||
def request(query: str, params: "OnlineParams"):
|
||||
"""Assemble a Bing-Web request."""
|
||||
|
||||
engine_region = traits.get_region(params["searxng_locale"], traits.all_locale)
|
||||
@@ -109,13 +109,7 @@ def request(query: str, params: "OnlineParams") -> "OnlineParams":
|
||||
if locale_params:
|
||||
query_params.update(locale_params)
|
||||
|
||||
params["url"] = f"{base_url}?{urlencode(query_params)}"
|
||||
|
||||
# in some regions where geoblocking is employed (e.g. China),
|
||||
# www.bing.com redirects to the regional version of Bing
|
||||
params["allow_redirects"] = True
|
||||
|
||||
return params
|
||||
params["url"] = f"{base_url}/search?{urlencode(query_params)}"
|
||||
|
||||
|
||||
def response(resp: "SXNG_Response") -> list[dict[str, t.Any]]:
|
||||
|
||||
Reference in New Issue
Block a user