From 71de593a5b9025e360da32813e9efeaeaa4992b2 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Sat, 26 Mar 2016 02:07:52 +0100 Subject: [PATCH] [fix] bing images page change --- searx/engines/bing_images.py | 2 +- tests/unit/engines/test_bing_images.py | 162 ++----------------------- 2 files changed, 10 insertions(+), 154 deletions(-) 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)