Skip to content

SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.

[fix] handle missing images in google news

Adam Tauber0171db5c3f6a
diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py
index 37253c6a7..11357f3e6 100644
--- a/searx/engines/google_news.py
+++ b/searx/engines/google_news.py
@@ -70,9 +70,9 @@ def response(resp):
'content': ''.join(result.xpath('.//div[@class="st"]//text()')),
}
- img = result.xpath('.//img/@src')[0]
- if img and not img.startswith('data'):
- r['img_src'] = img
+ imgs = result.xpath('.//img/@src')
+ if len(imgs) and not imgs[0].startswith('data'):
+ r['img_src'] = imgs[0]
results.append(r)