summaryrefslogtreecommitdiff
path: root/searx/engines/wolframalpha_api.py
diff options
context:
space:
mode:
authora01200356 <a01200356@itesm.mx>2015-12-30 00:53:15 -0600
committera01200356 <a01200356@itesm.mx>2015-12-30 00:53:15 -0600
commitbe54e5269a982e272e2fe8a5064ed898373c9063 (patch)
treeb2faba6828ca1513156afa0fb762447f4fb4006d /searx/engines/wolframalpha_api.py
parent5ed8f4da80ecd119173d7db871256be8484a9ecb (diff)
downloadsearxng-be54e5269a982e272e2fe8a5064ed898373c9063.tar.gz
searxng-be54e5269a982e272e2fe8a5064ed898373c9063.zip
Add tests for the Wolfram Alpha engines (both API and NO API versions)
Diffstat (limited to 'searx/engines/wolframalpha_api.py')
-rw-r--r--searx/engines/wolframalpha_api.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/searx/engines/wolframalpha_api.py b/searx/engines/wolframalpha_api.py
index d61d25747..4c99eac95 100644
--- a/searx/engines/wolframalpha_api.py
+++ b/searx/engines/wolframalpha_api.py
@@ -48,13 +48,16 @@ def response(resp):
if search_results.xpath('/queryresult[attribute::success="false"]'):
return []
- # parse result
- result = search_results.xpath('//pod[attribute::primary="true"]/subpod/plaintext')[0].text
- result = replace_pua_chars(result)
+ # parse answer
+ answer = search_results.xpath('//pod[attribute::primary="true"]/subpod/plaintext')
+ if not answer:
+ return results
+
+ answer = replace_pua_chars(answer[0].text)
# append result
# TODO: shouldn't it bind the source too?
- results.append({'answer': result})
+ results.append({'answer': answer})
# return results
return results