Sfoglia il codice sorgente

[fix] unescape htmlentities in wolframalpha_noapi's answer

a01200356 9 anni fa
parent
commit
576d37f256
2 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 6
    1
      searx/engines/wolframalpha_noapi.py
  2. 2
    1
      searx/settings.yml

+ 6
- 1
searx/engines/wolframalpha_noapi.py Vedi File

@@ -12,6 +12,7 @@ from re import search, sub
12 12
 from json import loads
13 13
 from urllib import urlencode
14 14
 from lxml import html
15
+import HTMLParser
15 16
 
16 17
 # search-url
17 18
 url = 'http://www.wolframalpha.com/'
@@ -62,7 +63,11 @@ def response(resp):
62 63
         # extract answer from json
63 64
         answer = line[line.find('{'):line.rfind('}')+1]
64 65
         answer = loads(answer.encode('unicode-escape'))
65
-        answer = answer['stringified'].decode('unicode-escape')
66
+        answer = answer['stringified']
67
+
68
+        # clean plaintext answer
69
+        h = HTMLParser.HTMLParser()
70
+        answer = h.unescape(answer.decode('unicode-escape'))
66 71
         answer = sub(r'\\', '', answer)
67 72
 
68 73
         results.append({'answer': answer})

+ 2
- 1
searx/settings.yml Vedi File

@@ -305,9 +305,10 @@ engines:
305 305
     # You can use the engine using the official stable API, but you need an API key
306 306
     # See : http://products.wolframalpha.com/api/
307 307
     #    engine : wolframalpha_api
308
-    #    api_key: '5952JX-X52L3VKWT8' # required!
308
+    #    api_key: '' # required!
309 309
     engine : wolframalpha_noapi
310 310
     timeout: 6.0
311
+    disabled : True
311 312
 
312 313
 #The blekko technology and team have joined IBM Watson! -> https://blekko.com/
313 314
 #  - name : blekko images