diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index 9d51428cc..efe46812a 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -49,8 +49,6 @@ def response(resp): # parse results for result in dom.xpath('//div[@data-ved]'): - data_url = result.xpath('./a/@href')[0] - data_query = {k: v[0] for k, v in parse_qs(data_url.split('?', 1)[1]).iteritems()} metadata = loads(result.xpath('./div[@class="rg_meta"]/text()')[0]) @@ -60,11 +58,11 @@ def response(resp): thumbnail_src = thumbnail_src.replace("http://", "https://") # append result - results.append({'url': data_query['imgrefurl'], + results.append({'url': metadata['ru'], 'title': metadata['pt'], 'content': metadata['s'], - 'thumbnail_src': metadata['tu'], - 'img_src': data_query['imgurl'], + 'thumbnail_src': thumbnail_src, + 'img_src': metadata['ou'], 'template': 'images.html'}) # return results diff --git a/tests/unit/engines/test_google_images.py b/tests/unit/engines/test_google_images.py index 876d0af1e..5f184e00c 100644 --- a/tests/unit/engines/test_google_images.py +++ b/tests/unit/engines/test_google_images.py @@ -41,7 +41,7 @@ class TestGoogleImagesEngine(SearxTestCase):
@@ -52,7 +52,7 @@ class TestGoogleImagesEngine(SearxTestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 1) self.assertEqual(results[0]['title'], u'South Arrow Clip Art at Clker.com - vector clip art online ...') - self.assertEqual(results[0]['url'], 'http://www.clker.com/clipart-south-arrow.html') + self.assertEqual(results[0]['url'], 'a') self.assertEqual(results[0]['thumbnail_src'], 'https://thumbnail.url/') - self.assertEqual(results[0]['img_src'], 'http://www.clker.com/cliparts/H/X/l/b/0/0/south-arrow-hi.png') + self.assertEqual(results[0]['img_src'], 'b') self.assertEqual(results[0]['content'], 'Download this image as:')