diff options
author | a01200356 <a01200356@itesm.mx> | 2016-01-03 22:03:33 -0600 |
---|---|---|
committer | a01200356 <a01200356@itesm.mx> | 2016-01-03 22:03:33 -0600 |
commit | 2a15944b58089d84a930f36b42c6ef60d4e629b3 (patch) | |
tree | ee1733359b82fac2236f27e578ac7936e2d28f7d /searx/engines/wolframalpha_noapi.py | |
parent | d997265e5599333b4316561ca18a8f4131e3e2d9 (diff) | |
download | searxng-2a15944b58089d84a930f36b42c6ef60d4e629b3.tar.gz searxng-2a15944b58089d84a930f36b42c6ef60d4e629b3.zip |
[fix] test in wolframalpha_noapi
Diffstat (limited to 'searx/engines/wolframalpha_noapi.py')
-rw-r--r-- | searx/engines/wolframalpha_noapi.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/searx/engines/wolframalpha_noapi.py b/searx/engines/wolframalpha_noapi.py index 71ad3b281..442e894b5 100644 --- a/searx/engines/wolframalpha_noapi.py +++ b/searx/engines/wolframalpha_noapi.py @@ -41,8 +41,8 @@ def response(resp): # the answer is inside a js function # answer can be located in different 'pods', although by default it should be in pod_0200 - possible_locations = ['pod_0200\.push(.*)\n', - 'pod_0100\.push(.*)\n'] + possible_locations = ['pod_0200\.push\((.*)', + 'pod_0100\.push\((.*)'] # failed result if dom.xpath(failure_xpath): @@ -62,7 +62,10 @@ def response(resp): if line: # extract answer from json answer = line[line.find('{'):line.rfind('}')+1] - answer = loads(answer.encode('unicode-escape')) + try: + answer = loads(answer) + except Exception: + answer = loads(answer.encode('unicode-escape')) answer = answer['stringified'] # clean plaintext answer |