SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] yandex images: crashes when parsing images without fallback source (#6084)
Bnyrode49d27846ec
diff --git a/searx/engines/yandex.py b/searx/engines/yandex.pyindex 84d18ebe3..5e963475b 100644--- a/searx/engines/yandex.py+++ b/searx/engines/yandex.py@@ -87,7 +87,6 @@ def request(query, params):def response(resp):if search_type == 'web':-catch_bad_response(resp)dom = html.fromstring(resp.text)@@ -106,7 +105,6 @@ def response(resp):return resultsif search_type == 'images':-catch_bad_response(resp)html_data = html.fromstring(resp.text)@@ -127,22 +125,25 @@ def response(resp):for _, item_data in json_resp['initialState']['serpList']['items']['entities'].items():title = item_data['snippet']['title']source = item_data['snippet']['url']- thumb = item_data['image']- fullsize_image = item_data['viewerData']['dups'][0]['url']- height = item_data['viewerData']['dups'][0]['h']- width = item_data['viewerData']['dups'][0]['w']- filesize = item_data['viewerData']['dups'][0]['fileSizeInBytes']- humanized_filesize = humanize_bytes(filesize)++ image_source = item_data["viewerData"]["thumb"]+ for i in item_data['viewerData']['dups'] + item_data['viewerData']['preview']:+ if i["h"] > image_source["h"]:+ image_source = i++ humanized_filesize = None+ if image_source.get("fileSizeInBytes"):+ humanized_filesize = humanize_bytes(image_source["fileSizeInBytes"])results.append({'title': title,'url': source,- 'img_src': fullsize_image,+ 'img_src': image_source["url"],'filesize': humanized_filesize,- 'thumbnail_src': thumb,+ 'thumbnail_src': item_data["image"],'template': 'images.html',- 'resolution': f'{width} x {height}',+ 'resolution': f'{image_source["w"]} x {image_source["h"]}',})