Repository: searx/searx

Issue:
wolframalpha engine is broken
The wolframalpha engine appears to be broken in 0.15.0
```
searx-run[9330]: ERROR:searx.search:engine wolframalpha : exception : Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
searx-run[9330]: Traceback (most recent call last):
searx-run[9330]:   File "/nix/store/rf8v47ispmh7bp0rbl291ml1fivfs424-searx-0.15.0/lib/python3.6/site-packages/searx/search.py", line 104, in search_one_request_safe
searx-run[9330]:     search_results = search_one_request(engine, query, request_params)
searx-run[9330]:   File "/nix/store/rf8v47ispmh7bp0rbl291ml1fivfs424-searx-0.15.0/lib/python3.6/site-packages/searx/search.py", line 87, in search_one_request
searx-run[9330]:     return engine.response(response)
searx-run[9330]:   File "/nix/store/rf8v47ispmh7bp0rbl291ml1fivfs424-searx-0.15.0/lib/python3.6/site-packages/searx/engines/wolframalpha_api.py", line 68, in response
searx-run[9330]:     search_results = etree.XML(resp.text)
searx-run[9330]:   File "src/lxml/etree.pyx", line 3192, in lxml.etree.XML
searx-run[9330]:   File "src/lxml/parser.pxi", line 1872, in lxml.etree._parseMemoryDocument
searx-run[9330]: ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
```
wolframalpha engine is broken
The wolframalpha engine appears to be broken in 0.15.0
```
searx-run[9330]: ERROR:searx.search:engine wolframalpha : exception : Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
searx-run[9330]: Traceback (most recent call last):
searx-run[9330]:   File "/nix/store/rf8v47ispmh7bp0rbl291ml1fivfs424-searx-0.15.0/lib/python3.6/site-packages/searx/search.py", line 104, in search_one_request_safe
searx-run[9330]:     search_results = search_one_request(engine, query, request_params)
searx-run[9330]:   File "/nix/store/rf8v47ispmh7bp0rbl291ml1fivfs424-searx-0.15.0/lib/python3.6/site-packages/searx/search.py", line 87, in search_one_request
searx-run[9330]:     return engine.response(response)
searx-run[9330]:   File "/nix/store/rf8v47ispmh7bp0rbl291ml1fivfs424-searx-0.15.0/lib/python3.6/site-packages/searx/engines/wolframalpha_api.py", line 68, in response
searx-run[9330]:     search_results = etree.XML(resp.text)
searx-run[9330]:   File "src/lxml/etree.pyx", line 3192, in lxml.etree.XML
searx-run[9330]:   File "src/lxml/parser.pxi", line 1872, in lxml.etree._parseMemoryDocument
searx-run[9330]: ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
```


Discussion:
Could you please share an example search query which leads to this exception? I have failed to come up with one.
I have configured searx to use the `wolframalpha_api` engine with a valid api key (I tested it with curl). Enabling the science category any query results in this error. 
Could you please share an example search query which leads to this exception? I have failed to come up with one.
I have configured searx to use the `wolframalpha_api` engine with a valid api key (I tested it with curl). Enabling the science category any query results in this error. 

Resolving patch:
diff --git a/searx/engines/wolframalpha_api.py b/searx/engines/wolframalpha_api.py
--- 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)
+    search_results = etree.XML(resp.content)
 
     # return empty array if there are no results
     if search_results.xpath(failure_xpath):


Test patch:
diff --git a/tests/unit/engines/test_wolframalpha_api.py b/tests/unit/engines/test_wolframalpha_api.py
--- a/tests/unit/engines/test_wolframalpha_api.py
+++ b/tests/unit/engines/test_wolframalpha_api.py
@@ -35,7 +35,7 @@ def test_response(self):
         xml = '''<?xml version='1.0' encoding='UTF-8'?>
         <queryresult success='false' error='false' />
         '''
-        response = mock.Mock(text=xml.encode('utf-8'))
+        response = mock.Mock(content=xml.encode('utf-8'))
         self.assertEqual(wolframalpha_api.response(response), [])
 
         # test basic case
@@ -83,7 +83,7 @@ def test_response(self):
              </pod>
         </queryresult>
         """
-        response = mock.Mock(text=xml, request=request)
+        response = mock.Mock(content=xml, request=request)
         results = wolframalpha_api.response(response)
         self.assertEqual(type(results), list)
         self.assertEqual(len(results), 2)
@@ -144,7 +144,7 @@ def test_response(self):
             </pod>
         </queryresult>
         """
-        response = mock.Mock(text=xml, request=request)
+        response = mock.Mock(content=xml, request=request)
         results = wolframalpha_api.response(response)
         self.assertEqual(type(results), list)
         self.assertEqual(len(results), 2)