diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2015-01-17 20:25:13 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2015-01-17 20:25:13 +0100 |
| commit | e3edded60f96aea7ce25465fd0dc49914d4fe9c8 (patch) | |
| tree | d67dd90de2b3983604e127c2c5e06de3aede9577 /searx/engines/500px.py | |
| parent | 975b6b5b09b8b6366dc3103d04ca3636da927ebe (diff) | |
| parent | d910744efe02f6eedb8fcb7661b208b349f78b39 (diff) | |
Merge pull request #178 from Cqoicebordel/thumbnails
Thumbnails
Diffstat (limited to 'searx/engines/500px.py')
| -rw-r--r-- | searx/engines/500px.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/searx/engines/500px.py b/searx/engines/500px.py index 3b95619a1..f25678c24 100644 --- a/searx/engines/500px.py +++ b/searx/engines/500px.py @@ -14,6 +14,7 @@ from urllib import urlencode from urlparse import urljoin from lxml import html +import re # engine dependent config categories = ['images'] @@ -37,20 +38,25 @@ def response(resp): results = [] dom = html.fromstring(resp.text) + regex = re.compile('3\.jpg.*$') # parse results for result in dom.xpath('//div[@class="photo"]'): link = result.xpath('.//a')[0] url = urljoin(base_url, link.attrib.get('href')) title = result.xpath('.//div[@class="title"]//text()')[0] - img_src = link.xpath('.//img')[0].attrib['src'] + thumbnail_src = link.xpath('.//img')[0].attrib['src'] + # To have a bigger thumbnail, uncomment the next line + #thumbnail_src = regex.sub('4.jpg', thumbnail_src) content = result.xpath('.//div[@class="info"]//text()')[0] + img_src = regex.sub('2048.jpg', thumbnail_src) # append result results.append({'url': url, 'title': title, 'img_src': img_src, 'content': content, + 'thumbnail_src': thumbnail_src, 'template': 'images.html'}) # return results |