summaryrefslogtreecommitdiff
path: root/searx/engines/flickr.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-10-18 09:35:29 +0200
committerasciimoo <asciimoo@gmail.com>2013-10-18 09:35:29 +0200
commitb1a996ef4af4a15dcc7e25ff108560c60fd616ae (patch)
tree4594df56630e20df7c8fd4da6b49334ae5e68abc /searx/engines/flickr.py
parent3b85089e773172e240259baae180a175b3cbf63a (diff)
downloadsearxng-b1a996ef4af4a15dcc7e25ff108560c60fd616ae.tar.gz
searxng-b1a996ef4af4a15dcc7e25ff108560c60fd616ae.zip
[fix] several fixes
Diffstat (limited to 'searx/engines/flickr.py')
-rwxr-xr-xsearx/engines/flickr.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/searx/engines/flickr.py b/searx/engines/flickr.py
index 3c8d1d931..60e2b6f3b 100755
--- a/searx/engines/flickr.py
+++ b/searx/engines/flickr.py
@@ -4,26 +4,25 @@ from urllib import quote
from lxml import html
from urlparse import urljoin
-categories = ['img']
+categories = ['images']
base_url = 'https://secure.flickr.com/'
search_url = base_url+'search/?q='
def request(query, params):
global search_url
- print 'qqwerqwerqwerqwer'
query = quote(query.replace(' ', '+'), safe='+')
params['url'] = search_url + query
return params
def response(resp):
global base_url
- print 'asdfasdfasdf'
results = []
dom = html.fromstring(resp.text)
- for result in dom.xpath('//#thumbnails//a'):
+ 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'))
- title = result.xpath('./img')[0].attrib.get('alt')
- content = "<img src='%s'></img>" % result.xpath('./img')[0].attrib.get('src')
+ img = result.xpath('.//img')[0]
+ title = img.attrib.get('alt', '')
+ content = '<img src="%s" alt="%s" />' % (img.attrib.get('data-defer-src', ''), title)
results.append({'url': url, 'title': title, 'content': content})
return results