mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 19:00:10 +01:00
#607 - noapi fix
This commit is contained in:
parent
05206f86e3
commit
e145fdb86d
@ -8,9 +8,11 @@
|
|||||||
# @stable no
|
# @stable no
|
||||||
# @parse url, infobox
|
# @parse url, infobox
|
||||||
|
|
||||||
|
from cgi import escape
|
||||||
from json import loads
|
from json import loads
|
||||||
from time import time
|
from time import time
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
from lxml.etree import XML
|
||||||
|
|
||||||
from searx.poolrequests import get as http_get
|
from searx.poolrequests import get as http_get
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ search_url = url + 'input/json.jsp'\
|
|||||||
referer_url = url + 'input/?{query}'
|
referer_url = url + 'input/?{query}'
|
||||||
|
|
||||||
token = {'value': '',
|
token = {'value': '',
|
||||||
'last_updated': 0}
|
'last_updated': None}
|
||||||
|
|
||||||
# pods to display as image in infobox
|
# pods to display as image in infobox
|
||||||
# this pods do return a plaintext, but they look better and are more useful as images
|
# 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']
|
# TODO handle resp_json['queryresult']['assumptions']
|
||||||
result_chunks = []
|
result_chunks = []
|
||||||
infobox_title = None
|
infobox_title = ""
|
||||||
result = ""
|
result_content = ""
|
||||||
for pod in resp_json['queryresult']['pods']:
|
for pod in resp_json['queryresult']['pods']:
|
||||||
pod_id = pod.get('id', '')
|
pod_id = pod.get('id', '')
|
||||||
pod_title = pod.get('title', '')
|
pod_title = pod.get('title', '')
|
||||||
@ -99,8 +101,9 @@ def response(resp):
|
|||||||
if subpod['plaintext'] != '(requires interactivity)':
|
if subpod['plaintext'] != '(requires interactivity)':
|
||||||
result_chunks.append({'label': pod_title, 'value': subpod['plaintext']})
|
result_chunks.append({'label': pod_title, 'value': subpod['plaintext']})
|
||||||
|
|
||||||
if pod_is_result:
|
if pod_is_result or not result_content:
|
||||||
result = subpod['plaintext']
|
if pod_id != "Input":
|
||||||
|
result_content = pod_title + ': ' + subpod['plaintext']
|
||||||
|
|
||||||
elif 'img' in subpod:
|
elif 'img' in subpod:
|
||||||
result_chunks.append({'label': pod_title, 'image': subpod['img']})
|
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')}]})
|
'urls': [{'title': 'Wolfram|Alpha', 'url': resp.request.headers['Referer'].decode('utf8')}]})
|
||||||
|
|
||||||
results.append({'url': resp.request.headers['Referer'].decode('utf8'),
|
results.append({'url': resp.request.headers['Referer'].decode('utf8'),
|
||||||
'title': infobox_title + ' - Wolfram|Alpha',
|
'title': 'Wolfram|Alpha (' + infobox_title + ')',
|
||||||
'content': result})
|
'content': result_content})
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
Loading…
Reference in New Issue
Block a user