소스 검색

[fix] unescape htmlentities in wolframalpha_noapi's answer

a01200356 9 년 전
부모
커밋
576d37f256
2개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 6
    1
      searx/engines/wolframalpha_noapi.py
  2. 2
    1
      searx/settings.yml

+ 6
- 1
searx/engines/wolframalpha_noapi.py 파일 보기

12
 from json import loads
12
 from json import loads
13
 from urllib import urlencode
13
 from urllib import urlencode
14
 from lxml import html
14
 from lxml import html
15
+import HTMLParser
15
 
16
 
16
 # search-url
17
 # search-url
17
 url = 'http://www.wolframalpha.com/'
18
 url = 'http://www.wolframalpha.com/'
62
         # extract answer from json
63
         # extract answer from json
63
         answer = line[line.find('{'):line.rfind('}')+1]
64
         answer = line[line.find('{'):line.rfind('}')+1]
64
         answer = loads(answer.encode('unicode-escape'))
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
         answer = sub(r'\\', '', answer)
71
         answer = sub(r'\\', '', answer)
67
 
72
 
68
         results.append({'answer': answer})
73
         results.append({'answer': answer})

+ 2
- 1
searx/settings.yml 파일 보기

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