summaryrefslogtreecommitdiff
path: root/searx/engines/flickr.py
diff options
context:
space:
mode:
authorpw3t <romain@berthor.fr>2014-01-23 22:11:36 +0100
committerpw3t <romain@berthor.fr>2014-01-23 22:11:36 +0100
commit132681b3aaf5b330d9d19624038b51fe2ebfd8d5 (patch)
tree393114f41b487eea4b71dd4073903726310a1257 /searx/engines/flickr.py
parentd6b017efb5b51623a02c85690c7335cfc6674092 (diff)
parent59eeeaab87951fd6fa3302ec240db98902a20b2c (diff)
Merge branch 'master' of https://github.com/asciimoo/searx
Diffstat (limited to 'searx/engines/flickr.py')
-rw-r--r--searx/engines/flickr.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/searx/engines/flickr.py b/searx/engines/flickr.py
index a9832856d..d9554b99a 100644
--- a/searx/engines/flickr.py
+++ b/searx/engines/flickr.py
@@ -8,21 +8,27 @@ categories = ['images']
url = 'https://secure.flickr.com/'
search_url = url+'search/?{query}'
+results_xpath = '//div[@id="thumbnails"]//a[@class="rapidnofollow photo-click" and @data-track="photo-click"]' # noqa
+
def request(query, params):
params['url'] = search_url.format(query=urlencode({'q': query}))
return params
+
def response(resp):
global base_url
results = []
dom = html.fromstring(resp.text)
- for result in dom.xpath('//div[@id="thumbnails"]//a[@class="rapidnofollow photo-click" and @data-track="photo-click"]'):
+ for result in dom.xpath(results_xpath):
href = urljoin(url, result.attrib.get('href'))
img = result.xpath('.//img')[0]
title = img.attrib.get('alt', '')
img_src = img.attrib.get('data-defer-src')
if not img_src:
continue
- results.append({'url': href, 'title': title, 'img_src': img_src, 'template': 'images.html'})
+ results.append({'url': href,
+ 'title': title,
+ 'img_src': img_src,
+ 'template': 'images.html'})
return results