forked from zaclys/searxng
#607 - noapi fix
This commit is contained in:
parent
05206f86e3
commit
e145fdb86d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue