mirror of
https://github.com/searxng/searxng.git
synced 2025-07-19 03:09:25 +02:00
[fix] unescape htmlentities in wolframalpha_noapi's answer
This commit is contained in:
parent
16d6e758d7
commit
576d37f256
2 changed files with 8 additions and 2 deletions
|
@ -12,6 +12,7 @@ from re import search, sub
|
|||
from json import loads
|
||||
from urllib import urlencode
|
||||
from lxml import html
|
||||
import HTMLParser
|
||||
|
||||
# search-url
|
||||
url = 'http://www.wolframalpha.com/'
|
||||
|
@ -62,7 +63,11 @@ def response(resp):
|
|||
# extract answer from json
|
||||
answer = line[line.find('{'):line.rfind('}')+1]
|
||||
answer = loads(answer.encode('unicode-escape'))
|
||||
answer = answer['stringified'].decode('unicode-escape')
|
||||
answer = answer['stringified']
|
||||
|
||||
# clean plaintext answer
|
||||
h = HTMLParser.HTMLParser()
|
||||
answer = h.unescape(answer.decode('unicode-escape'))
|
||||
answer = sub(r'\\', '', answer)
|
||||
|
||||
results.append({'answer': answer})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue