summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--searx/engines/bing_news.py2
-rw-r--r--searx/engines/gigablast.py8
-rw-r--r--searx/tests/engines/test_bing_news.py12
3 files changed, 13 insertions, 9 deletions
diff --git a/searx/engines/bing_news.py b/searx/engines/bing_news.py
index 943bf882e..a2397c48e 100644
--- a/searx/engines/bing_news.py
+++ b/searx/engines/bing_news.py
@@ -68,7 +68,7 @@ def request(query, params):
def response(resp):
results = []
- rss = etree.fromstring(resp.text)
+ rss = etree.fromstring(resp.content)
ns = rss.nsmap
diff --git a/searx/engines/gigablast.py b/searx/engines/gigablast.py
index b852de9ba..cfc8e7159 100644
--- a/searx/engines/gigablast.py
+++ b/searx/engines/gigablast.py
@@ -13,6 +13,8 @@
from urllib import urlencode
from cgi import escape
from lxml import etree
+from random import randint
+from time import time
# engine dependent config
categories = ['general']
@@ -21,7 +23,7 @@ number_of_results = 5
# search-url, invalid HTTPS certificate
base_url = 'http://gigablast.com/'
-search_string = 'search?{query}&n={number_of_results}&s={offset}&xml=1&qh=0'
+search_string = 'search?{query}&n={number_of_results}&s={offset}&xml=1&qh=0&uxid={uxid}&rand={rand}'
# specific xpath variables
results_xpath = '//response//result'
@@ -37,7 +39,9 @@ def request(query, params):
search_path = search_string.format(
query=urlencode({'q': query}),
offset=offset,
- number_of_results=number_of_results)
+ number_of_results=number_of_results,
+ uxid=randint(10000, 10000000),
+ rand=int(time()))
params['url'] = base_url + search_path
diff --git a/searx/tests/engines/test_bing_news.py b/searx/tests/engines/test_bing_news.py
index c6c402650..a64d59b7b 100644
--- a/searx/tests/engines/test_bing_news.py
+++ b/searx/tests/engines/test_bing_news.py
@@ -28,10 +28,10 @@ class TestBingNewsEngine(SearxTestCase):
self.assertRaises(AttributeError, bing_news.response, '')
self.assertRaises(AttributeError, bing_news.response, '[]')
- response = mock.Mock(text='<html></html>')
+ response = mock.Mock(content='<html></html>')
self.assertEqual(bing_news.response(response), [])
- response = mock.Mock(text='<html></html>')
+ response = mock.Mock(content='<html></html>')
self.assertEqual(bing_news.response(response), [])
html = """<?xml version="1.0" encoding="utf-8" ?>
@@ -66,7 +66,7 @@ class TestBingNewsEngine(SearxTestCase):
</item>
</channel>
</rss>""" # noqa
- response = mock.Mock(text=html)
+ response = mock.Mock(content=html)
results = bing_news.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 2)
@@ -105,7 +105,7 @@ class TestBingNewsEngine(SearxTestCase):
</item>
</channel>
</rss>""" # noqa
- response = mock.Mock(text=html)
+ response = mock.Mock(content=html)
results = bing_news.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 1)
@@ -128,11 +128,11 @@ class TestBingNewsEngine(SearxTestCase):
</channel>
</rss>""" # noqa
- response = mock.Mock(text=html)
+ response = mock.Mock(content=html)
results = bing_news.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 0)
html = """<?xml version="1.0" encoding="utf-8" ?>gabarge"""
- response = mock.Mock(text=html)
+ response = mock.Mock(content=html)
self.assertRaises(lxml.etree.XMLSyntaxError, bing_news.response, response)