From 01d2fb9f703fee2a28cdb4c6583158054f9d7558 Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Sun, 19 Jul 2015 20:44:02 +0200 Subject: [PATCH 1/2] btdigg engine: fix text mojibake. Seeing on the official instance, searching with non-ascii character usually renders mojibake non-sense: http://searx.me/?q=%E9%A3%9F%E5%A0%82&categories=files Screenshot with broken: ![](https://imgrush.com/1NNr_Rpv-rt2.png) Screenshot of the fixed rendering: ![](https://imgrush.com/khe4M2P3VAyq.png) --- searx/engines/btdigg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/engines/btdigg.py b/searx/engines/btdigg.py index bde866146..192ed6ee9 100644 --- a/searx/engines/btdigg.py +++ b/searx/engines/btdigg.py @@ -38,7 +38,7 @@ def request(query, params): def response(resp): results = [] - dom = html.fromstring(resp.text) + dom = html.fromstring(resp.content) search_res = dom.xpath('//div[@id="search_res"]/table/tr') From c7c6c35ccd7373d2107b70b92badb9b70d31905f Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Sat, 14 Nov 2015 00:02:36 +0100 Subject: [PATCH 2/2] fix test faliures of btdigg engine. This fix the test failures related to 01d2fb9f703fee2a28cdb4c6583158054f9d7558 --- searx/tests/engines/test_btdigg.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/searx/tests/engines/test_btdigg.py b/searx/tests/engines/test_btdigg.py index 4947b71da..2721f4e7c 100644 --- a/searx/tests/engines/test_btdigg.py +++ b/searx/tests/engines/test_btdigg.py @@ -22,7 +22,7 @@ class TestBtdiggEngine(SearxTestCase): self.assertRaises(AttributeError, btdigg.response, '') self.assertRaises(AttributeError, btdigg.response, '[]') - response = mock.Mock(text='') + response = mock.Mock(content='') self.assertEqual(btdigg.response(response), []) html = """ @@ -82,7 +82,7 @@ class TestBtdiggEngine(SearxTestCase): """ - response = mock.Mock(text=html) + response = mock.Mock(content=html) results = btdigg.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) @@ -101,7 +101,7 @@ class TestBtdiggEngine(SearxTestCase): """ - response = mock.Mock(text=html) + response = mock.Mock(content=html) results = btdigg.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 0) @@ -367,7 +367,7 @@ class TestBtdiggEngine(SearxTestCase): """ - response = mock.Mock(text=html) + response = mock.Mock(content=html) results = btdigg.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 5)