logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git
commit: e145fdb86d0cd9dd8421ed63b3635f4bebcafa74
parent 05206f86e31402d2bc6010c814446cb9ac114085
Author: firebovine <firebovine@gmail.com>
Date:   Thu,  7 Jul 2016 19:41:33 -0400

#607 - noapi fix

Diffstat:

Msearx/engines/wolframalpha_noapi.py17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git 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