summaryrefslogtreecommitdiff
path: root/searx/engines/flickr.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-10-23 23:55:37 +0200
committerasciimoo <asciimoo@gmail.com>2013-10-23 23:55:37 +0200
commit74b6be3991dc62577aca295de839e51e6d0807d6 (patch)
tree5bf5df160e765dc7dc6897e640fd23a761df1d2e /searx/engines/flickr.py
parent39d229e1104dc10c7c7f00380c02d46118e3d895 (diff)
downloadsearxng-74b6be3991dc62577aca295de839e51e6d0807d6.tar.gz
searxng-74b6be3991dc62577aca295de839e51e6d0807d6.zip
[enh] engine cfg compatibilty
Diffstat (limited to 'searx/engines/flickr.py')
-rwxr-xr-xsearx/engines/flickr.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/searx/engines/flickr.py b/searx/engines/flickr.py
index 079c1e11c..04a24552a 100755
--- a/searx/engines/flickr.py
+++ b/searx/engines/flickr.py
@@ -1,18 +1,16 @@
#!/usr/bin/env python
-from urllib import quote
+from urllib import urlencode
from lxml import html
from urlparse import urljoin
categories = ['images']
-base_url = 'https://secure.flickr.com/'
-search_url = base_url+'search/?q='
+url = 'https://secure.flickr.com/'
+search_url = url+'search/?q={query}'
def request(query, params):
- global search_url
- query = quote(query.replace(' ', '+'), safe='+')
- params['url'] = search_url + query
+ params['url'] = search_url.format(query=urlencode({'q': query}))
return params
def response(resp):
@@ -20,11 +18,11 @@ def response(resp):
results = []
dom = html.fromstring(resp.text)
for result in dom.xpath('//div[@id="thumbnails"]//a[@class="rapidnofollow photo-click" and @data-track="photo-click"]'):
- url = urljoin(base_url, result.attrib.get('href'))
+ 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': url, 'title': title, 'img_src': img_src, 'template': 'images.html'})
+ results.append({'url': href, 'title': title, 'img_src': img_src, 'template': 'images.html'})
return results