[fix] engine: bing images - remove market place argument mkt (#6699)

The ``mkt`` argument does no longer exists and the ``async`` argument has been
renamed to ``mmasync``.

For still unknown reasons (IP based?), some users had to observe that the title
was missing [1].  I myself was not able to reproduce this error, however the
evaluation of the title was additionally expanded by the attribute value of the
``<a title=".."`` element.

Related:

- [1] https://github.com/searxng/searxng/pull/6690#issuecomment-5636811572

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser
2026-09-12 08:49:08 +02:00
committed by Markus Heiser
parent 87bf8c86ed
commit 923a307454
2 changed files with 14 additions and 11 deletions

View File

@@ -62,8 +62,8 @@ def get_locale_params(engine_region: str | None) -> dict[str, str] | None:
The ``mkt`` parameter takes a full ``<language>-<country>`` code. The ``mkt`` parameter takes a full ``<language>-<country>`` code.
This function is shared with :py:mod:`searx.engines.bing_images`, This function is shared with :py:mod:`searx.engines.bing_news`, and
:py:mod:`searx.engines.bing_news`, and :py:mod:`searx.engines.bing_videos`. :py:mod:`searx.engines.bing_videos`.
""" """
if not engine_region or engine_region == "clear": if not engine_region or engine_region == "clear":

View File

@@ -6,10 +6,7 @@ from urllib.parse import urlencode
from lxml import html from lxml import html
from searx.engines.bing import ( # pylint: disable=unused-import from searx.engines.bing import fetch_traits # pylint: disable=unused-import
fetch_traits,
get_locale_params,
)
# about # about
about = { about = {
@@ -44,18 +41,21 @@ def request(query, params):
engine_region = traits.get_region(params["searxng_locale"], traits.all_locale) engine_region = traits.get_region(params["searxng_locale"], traits.all_locale)
# build URL query # build URL query
# - example: https://www.bing.com/images/async?q=foo&async=1&first=1&count=35 # - example: https://www.bing.com/images/async?q=foo&mmasync=1&first=1&count=35
query_params = { query_params = {
"q": query, "q": query,
"async": "1", "mmasync": "1",
# to simplify the page count lets use the default of 35 images per page # to simplify the page count lets use the default of 35 images per page
"first": (int(params.get("pageno", 1)) - 1) * 35 + 1, "first": (int(params.get("pageno", 1)) - 1) * 35 + 1,
"count": 35, "count": 35,
} }
locale_params = get_locale_params(engine_region) if engine_region and engine_region != "clear":
if locale_params: lang, _, cc = engine_region.partition("-")
query_params.update(locale_params) query_params["setlang"] = lang
if cc:
query_params["cc"] = cc
# time range # time range
# - example: one year (525600 minutes) 'qft=filterui:age-lt525600' # - example: one year (525600 minutes) 'qft=filterui:age-lt525600'
@@ -79,6 +79,9 @@ def response(resp):
metadata = json.loads(result.xpath('.//a[@class="iusc"]/@m')[0]) metadata = json.loads(result.xpath('.//a[@class="iusc"]/@m')[0])
title = " ".join(result.xpath('.//div[@class="infnmpt"]//a/text()')).strip() title = " ".join(result.xpath('.//div[@class="infnmpt"]//a/text()')).strip()
if not title:
title = result.xpath('.//div[@class="infnmpt"]//a/@title')[0]
img_format = " ".join(result.xpath('.//div[@class="imgpt"]/div/span/text()')).strip().split(" · ") img_format = " ".join(result.xpath('.//div[@class="imgpt"]/div/span/text()')).strip().split(" · ")
source = " ".join(result.xpath('.//div[@class="imgpt"]//div[@class="lnkw"]//a/text()')).strip() source = " ".join(result.xpath('.//div[@class="imgpt"]//div[@class="lnkw"]//a/text()')).strip()
results.append( results.append(