diff --git a/searx/engines/bing_images.py b/searx/engines/bing_images.py index 2664b795..38452039 100644 --- a/searx/engines/bing_images.py +++ b/searx/engines/bing_images.py @@ -69,7 +69,7 @@ def response(resp): dom = html.fromstring(resp.text) # parse results - for result in dom.xpath('//div[@class="dg_u"]'): + for result in dom.xpath('//div[@class="dg_u"]/div'): link = result.xpath('./a')[0] # parse json-data (it is required to add a space, to make it parsable) diff --git a/tests/unit/engines/test_bing_images.py b/tests/unit/engines/test_bing_images.py index 88538d8f..9d8ec18a 100644 --- a/tests/unit/engines/test_bing_images.py +++ b/tests/unit/engines/test_bing_images.py @@ -38,12 +38,12 @@ class TestBingImagesEngine(SearxTestCase): self.assertEqual(bing_images.response(response), []) html = """ -
+
-
+
""" # noqa html = html.replace('\r\n', '').replace('\n', '').replace('\r', '') response = mock.Mock(text=html) @@ -78,7 +78,7 @@ class TestBingImagesEngine(SearxTestCase): self.assertEqual(len(results), 0) html = """ -
+
-
-
+
+
-
-
+
+
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
+
""" html = html.replace('\r\n', '').replace('\n', '').replace('\r', '') response = mock.Mock(text=html) results = bing_images.response(response) self.assertEqual(type(results), list) - self.assertEqual(len(results), 10) + self.assertEqual(len(results), 3)