diff --git a/searx/engines/bing_news.py b/searx/engines/bing_news.py index 1a71aed6d800975bcbfa445714f33044072cd5a1..39048a1fcfb16885430b3311ac70cd7e3249b8a0 100644 --- a/searx/engines/bing_news.py +++ b/searx/engines/bing_news.py @@ -82,7 +82,7 @@ def request(query, params): def response(resp): results = [] - rss = etree.fromstring(resp.content.encode()) + rss = etree.fromstring(resp.content) ns = rss.nsmap diff --git a/searx/engines/wolframalpha_api.py b/searx/engines/wolframalpha_api.py index 383d8c3b36902796b3e28894b580da3d915bbf99..a5cebeec898ae1fe3d9f90f7a40c57cfd8eba194 100644 --- a/searx/engines/wolframalpha_api.py +++ b/searx/engines/wolframalpha_api.py @@ -65,7 +65,7 @@ def replace_pua_chars(text): def response(resp): results = [] - search_results = etree.XML(resp.text.encode()) + search_results = etree.XML(resp.text) # return empty array if there are no results if search_results.xpath(failure_xpath): diff --git a/tests/unit/engines/test_bing_news.py b/tests/unit/engines/test_bing_news.py index a02e75e5eb5cbbf82133511b508df8b304b7364d..33cf2629f9c0d74da216244267bf4c5de30ef8e8 100644 --- a/tests/unit/engines/test_bing_news.py +++ b/tests/unit/engines/test_bing_news.py @@ -33,13 +33,13 @@ class TestBingNewsEngine(TestCase): self.assertRaises(AttributeError, bing_news.response, '') self.assertRaises(AttributeError, bing_news.response, '[]') - response = mock.Mock(content='') + response = mock.Mock(content=b'') self.assertEqual(bing_news.response(response), []) - response = mock.Mock(content='') + response = mock.Mock(content=b'') self.assertEqual(bing_news.response(response), []) - html = """ + html = b""" python - Bing News @@ -84,7 +84,7 @@ class TestBingNewsEngine(TestCase): self.assertEqual(results[1]['content'], 'Another Article Content') self.assertNotIn('img_src', results[1]) - html = """ + html = b""" python - Bing News @@ -119,7 +119,7 @@ class TestBingNewsEngine(TestCase): self.assertEqual(results[0]['content'], 'Article Content') self.assertEqual(results[0]['img_src'], 'http://another.bing.com/image') - html = """ + html = b""" python - Bing News @@ -138,6 +138,6 @@ class TestBingNewsEngine(TestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 0) - html = """gabarge""" + html = b"""gabarge""" response = mock.Mock(content=html) self.assertRaises(lxml.etree.XMLSyntaxError, bing_news.response, response) diff --git a/tests/unit/engines/test_wolframalpha_api.py b/tests/unit/engines/test_wolframalpha_api.py index 586f9061fca2a1aeca3e6840ce38abb17d75d6ba..192d32045a1259b53a621131372e63c6a085dd58 100644 --- a/tests/unit/engines/test_wolframalpha_api.py +++ b/tests/unit/engines/test_wolframalpha_api.py @@ -32,14 +32,14 @@ class TestWolframAlphaAPIEngine(TestCase): request = Request(headers={'Referer': referer_url}) # test failure - xml = ''' + xml = b''' ''' response = mock.Mock(text=xml) self.assertEqual(wolframalpha_api.response(response), []) # test basic case - xml = """ + xml = b""" + xml = b"""