forked from Icycoide/searxng
[enh] engine cfg compatibilty
This commit is contained in:
parent
39d229e110
commit
74b6be3991
9 changed files with 36 additions and 39 deletions
|
@ -5,15 +5,14 @@ from json import loads
|
|||
|
||||
categories = ['images']
|
||||
|
||||
search_url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&start=0&rsz=large&safe=off&filter=off&'
|
||||
url = 'https://ajax.googleapis.com/'
|
||||
search_url = url + 'ajax/services/search/images?v=1.0&start=0&rsz=large&safe=off&filter=off&{query}'
|
||||
|
||||
def request(query, params):
|
||||
global search_url
|
||||
params['url'] = search_url + urlencode({'q': query})
|
||||
return params
|
||||
|
||||
def response(resp):
|
||||
global base_url
|
||||
results = []
|
||||
search_res = loads(resp.text)
|
||||
if not search_res.get('responseData'):
|
||||
|
@ -21,9 +20,9 @@ def response(resp):
|
|||
if not search_res['responseData'].get('results'):
|
||||
return []
|
||||
for result in search_res['responseData']['results']:
|
||||
url = result['originalContextUrl']
|
||||
href = result['originalContextUrl']
|
||||
title = result['title']
|
||||
if not result['url']:
|
||||
continue
|
||||
results.append({'url': url, 'title': title, 'content': '', 'img_src': result['url'], 'template': 'images.html'})
|
||||
results.append({'url': href, 'title': title, 'content': '', 'img_src': result['url'], 'template': 'images.html'})
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue