From 3a6d3e33778fb25dc64002a21681208d9fc509da Mon Sep 17 00:00:00 2001 From: asciimoo Date: Tue, 22 Oct 2013 23:34:45 +0200 Subject: [PATCH] [enh][mod] using image template rendering --- searx/engines/deviantart.py | 5 +++-- searx/engines/flickr.py | 6 ++++-- searx/engines/google_images.py | 5 +---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/searx/engines/deviantart.py b/searx/engines/deviantart.py index d598507ac..95d96968d 100644 --- a/searx/engines/deviantart.py +++ b/searx/engines/deviantart.py @@ -24,6 +24,7 @@ def response(resp): url = urljoin(base_url, link.attrib.get('href')) title_links = result.xpath('.//span[@class="details"]//a[contains(@class, "t")]') title = ''.join(title_links[0].xpath('.//text()')) - content = html.tostring(link)+'
'+link.attrib.get('title', '') - results.append({'url': url, 'title': title, 'content': content}) + img_src = link.xpath('.//img')[0].attrib['src'] + print img_src + results.append({'url': url, 'title': title, 'img_src': img_src, 'template': 'images.html'}) return results diff --git a/searx/engines/flickr.py b/searx/engines/flickr.py index 60e2b6f3b..079c1e11c 100755 --- a/searx/engines/flickr.py +++ b/searx/engines/flickr.py @@ -23,6 +23,8 @@ def response(resp): url = urljoin(base_url, result.attrib.get('href')) img = result.xpath('.//img')[0] title = img.attrib.get('alt', '') - content = '%s' % (img.attrib.get('data-defer-src', ''), title) - results.append({'url': url, 'title': title, 'content': content}) + img_src = img.attrib.get('data-defer-src') + if not img_src: + continue + results.append({'url': url, 'title': title, 'img_src': img_src, 'template': 'images.html'}) return results diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index bb7209ca6..2db4fb0e2 100755 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -23,8 +23,5 @@ def response(resp): for result in search_res['responseData']['results']: url = result['originalContextUrl'] title = result['title'] - content = '' % (result['url'], result['url'], title) - if result['content']: - content += '
'+result['content'] - results.append({'url': url, 'title': title, 'content': content}) + results.append({'url': url, 'title': title, 'content': '', 'img_src': result['url'], 'template': 'images.html'}) return results