forked from zaclys/searxng
[enh][mod] using image template rendering
This commit is contained in:
parent
31471ed936
commit
3a6d3e3377
|
@ -24,6 +24,7 @@ def response(resp):
|
||||||
url = urljoin(base_url, link.attrib.get('href'))
|
url = urljoin(base_url, link.attrib.get('href'))
|
||||||
title_links = result.xpath('.//span[@class="details"]//a[contains(@class, "t")]')
|
title_links = result.xpath('.//span[@class="details"]//a[contains(@class, "t")]')
|
||||||
title = ''.join(title_links[0].xpath('.//text()'))
|
title = ''.join(title_links[0].xpath('.//text()'))
|
||||||
content = html.tostring(link)+'<br />'+link.attrib.get('title', '')
|
img_src = link.xpath('.//img')[0].attrib['src']
|
||||||
results.append({'url': url, 'title': title, 'content': content})
|
print img_src
|
||||||
|
results.append({'url': url, 'title': title, 'img_src': img_src, 'template': 'images.html'})
|
||||||
return results
|
return results
|
||||||
|
|
|
@ -23,6 +23,8 @@ def response(resp):
|
||||||
url = urljoin(base_url, result.attrib.get('href'))
|
url = urljoin(base_url, result.attrib.get('href'))
|
||||||
img = result.xpath('.//img')[0]
|
img = result.xpath('.//img')[0]
|
||||||
title = img.attrib.get('alt', '')
|
title = img.attrib.get('alt', '')
|
||||||
content = '<img src="%s" alt="%s" />' % (img.attrib.get('data-defer-src', ''), title)
|
img_src = img.attrib.get('data-defer-src')
|
||||||
results.append({'url': url, 'title': title, 'content': content})
|
if not img_src:
|
||||||
|
continue
|
||||||
|
results.append({'url': url, 'title': title, 'img_src': img_src, 'template': 'images.html'})
|
||||||
return results
|
return results
|
||||||
|
|
|
@ -23,8 +23,5 @@ def response(resp):
|
||||||
for result in search_res['responseData']['results']:
|
for result in search_res['responseData']['results']:
|
||||||
url = result['originalContextUrl']
|
url = result['originalContextUrl']
|
||||||
title = result['title']
|
title = result['title']
|
||||||
content = '<a href="%s"><img src="%s" title="%s" style="max-width: 500px; "/></a>' % (result['url'], result['url'], title)
|
results.append({'url': url, 'title': title, 'content': '', 'img_src': result['url'], 'template': 'images.html'})
|
||||||
if result['content']:
|
|
||||||
content += '<br />'+result['content']
|
|
||||||
results.append({'url': url, 'title': title, 'content': content})
|
|
||||||
return results
|
return results
|
||||||
|
|
Loading…
Reference in New Issue