mirror of
https://github.com/searxng/searxng.git
synced 2026-05-26 12:50:14 +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]]:
|
||||
|
||||
@@ -34,7 +34,7 @@ time_map = {
|
||||
"year": 60 * 24 * 365,
|
||||
}
|
||||
|
||||
base_url = "https://www.bing.com/images/async"
|
||||
base_url = "https://www.bing.com"
|
||||
"""Bing-Image search URL"""
|
||||
|
||||
|
||||
@@ -64,9 +64,7 @@ def request(query, params):
|
||||
if params["time_range"]:
|
||||
query_params["qft"] = "filterui:age-lt%s" % time_map[params["time_range"]]
|
||||
|
||||
params["url"] = base_url + "?" + urlencode(query_params)
|
||||
|
||||
return params
|
||||
params["url"] = base_url + "/images/async?" + urlencode(query_params)
|
||||
|
||||
|
||||
def response(resp):
|
||||
|
||||
@@ -44,7 +44,7 @@ time_map = {
|
||||
difference of *last day* and *last week* in the result list is just marginally.
|
||||
Bing does not have news range ``year`` / we use ``month`` instead."""
|
||||
|
||||
base_url = "https://www.bing.com/news/infinitescrollajax"
|
||||
base_url = "https://www.bing.com"
|
||||
"""Bing (News) search URL"""
|
||||
|
||||
|
||||
@@ -74,9 +74,7 @@ def request(query, params):
|
||||
if params["time_range"]:
|
||||
query_params["qft"] = time_map.get(params["time_range"], 'interval="9"')
|
||||
|
||||
params["url"] = base_url + "?" + urlencode(query_params)
|
||||
|
||||
return params
|
||||
params["url"] = base_url + "/news/infinitescrollajax?" + urlencode(query_params)
|
||||
|
||||
|
||||
def response(resp):
|
||||
|
||||
@@ -29,7 +29,7 @@ paging = True
|
||||
safesearch = True
|
||||
time_range_support = True
|
||||
|
||||
base_url = "https://www.bing.com/videos/asyncv2"
|
||||
base_url = "https://www.bing.com"
|
||||
"""Bing-Video search URL"""
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ def request(query, params):
|
||||
query_params["form"] = "VRFLTR"
|
||||
query_params["qft"] = " filterui:videoage-lt%s" % time_map[params["time_range"]]
|
||||
|
||||
params["url"] = base_url + "?" + urlencode(query_params)
|
||||
params["url"] = base_url + "/videos/asyncv2?" + urlencode(query_params)
|
||||
|
||||
return params
|
||||
|
||||
|
||||
@@ -531,18 +531,22 @@ engines:
|
||||
engine: bing
|
||||
shortcut: bi
|
||||
disabled: true
|
||||
# base_url: https://cn.bing.com # for instances hosted in China
|
||||
|
||||
- name: bing images
|
||||
engine: bing_images
|
||||
shortcut: bii
|
||||
# base_url: https://cn.bing.com # for instances hosted in China
|
||||
|
||||
- name: bing news
|
||||
engine: bing_news
|
||||
shortcut: bin
|
||||
# base_url: https://cn.bing.com # for instances hosted in China
|
||||
|
||||
- name: bing videos
|
||||
engine: bing_videos
|
||||
shortcut: biv
|
||||
# base_url: https://cn.bing.com # for instances hosted in China
|
||||
|
||||
- name: bitchute
|
||||
engine: bitchute
|
||||
|
||||
Reference in New Issue
Block a user