diff options
author | firebovine <firebovine@gmail.com> | 2016-07-07 19:41:33 -0400 |
---|---|---|
committer | firebovine <firebovine@gmail.com> | 2016-09-10 17:43:12 -0400 |
commit | e145fdb86d0cd9dd8421ed63b3635f4bebcafa74 (patch) | |
tree | 10072f1a5e9ae8e46a9f198402fdd7a4eb8d46fd /searx/engines/wolframalpha_noapi.py | |
parent | 05206f86e31402d2bc6010c814446cb9ac114085 (diff) | |
download | searxng-e145fdb86d0cd9dd8421ed63b3635f4bebcafa74.tar.gz searxng-e145fdb86d0cd9dd8421ed63b3635f4bebcafa74.zip |
#607 - noapi fix
Diffstat (limited to 'searx/engines/wolframalpha_noapi.py')
-rw-r--r-- | searx/engines/wolframalpha_noapi.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/searx/engines/wolframalpha_noapi.py b/searx/engines/wolframalpha_noapi.py index 80a510e3a..e318d93e6 100644 --- a/searx/engines/wolframalpha_noapi.py +++ b/searx/engines/wolframalpha_noapi.py @@ -8,9 +8,11 @@ # @stable no # @parse url, infobox +from cgi import escape from json import loads from time import time from urllib import urlencode +from lxml.etree import XML from searx.poolrequests import get as http_get @@ -34,7 +36,7 @@ search_url = url + 'input/json.jsp'\ referer_url = url + 'input/?{query}' token = {'value': '', - 'last_updated': 0} + 'last_updated': None} # pods to display as image in infobox # this pods do return a plaintext, but they look better and are more useful as images @@ -80,8 +82,8 @@ def response(resp): # TODO handle resp_json['queryresult']['assumptions'] result_chunks = [] - infobox_title = None - result = "" + infobox_title = "" + result_content = "" for pod in resp_json['queryresult']['pods']: pod_id = pod.get('id', '') pod_title = pod.get('title', '') @@ -99,8 +101,9 @@ def response(resp): if subpod['plaintext'] != '(requires interactivity)': result_chunks.append({'label': pod_title, 'value': subpod['plaintext']}) - if pod_is_result: - result = subpod['plaintext'] + if pod_is_result or not result_content: + if pod_id != "Input": + result_content = pod_title + ': ' + subpod['plaintext'] elif 'img' in subpod: result_chunks.append({'label': pod_title, 'image': subpod['img']}) @@ -113,7 +116,7 @@ def response(resp): 'urls': [{'title': 'Wolfram|Alpha', 'url': resp.request.headers['Referer'].decode('utf8')}]}) results.append({'url': resp.request.headers['Referer'].decode('utf8'), - 'title': infobox_title + ' - Wolfram|Alpha', - 'content': result}) + 'title': 'Wolfram|Alpha (' + infobox_title + ')', + 'content': result_content}) return results |