From 5b28c9109f58685e14da17a83e4ee0f28c9d53c4 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 21 Nov 2021 09:54:05 +0100 Subject: [PATCH] [fix] google images: @href index 0 not found Sometimes there is no href in the `` tag of a *link_node* [1]. [1] https://github.com/searxng/searxng/issues/532 Reported-by: @TheEssem Signed-off-by: Markus Heiser --- searx/engines/google_images.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index ffdd6675..61d291e3 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -172,7 +172,10 @@ def response(resp): thumbnail_src = '' link_node = eval_xpath_getindex(img_node, '../../../a[2]', 0) - url = eval_xpath_getindex(link_node, '@href', 0) + url = eval_xpath_getindex(link_node, '@href', 0, None) + if url is None: + logger.error("missing @href in node: %s", html.tostring(link_node)) + continue pub_nodes = eval_xpath(link_node, './div/div') pub_descr = img_alt