diff options
author | asciimoo <asciimoo@gmail.com> | 2013-10-18 09:35:29 +0200 |
---|---|---|
committer | asciimoo <asciimoo@gmail.com> | 2013-10-18 09:35:29 +0200 |
commit | b1a996ef4af4a15dcc7e25ff108560c60fd616ae (patch) | |
tree | 4594df56630e20df7c8fd4da6b49334ae5e68abc /searx/engines/flickr.py | |
parent | 3b85089e773172e240259baae180a175b3cbf63a (diff) | |
download | searxng-b1a996ef4af4a15dcc7e25ff108560c60fd616ae.tar.gz searxng-b1a996ef4af4a15dcc7e25ff108560c60fd616ae.zip |
[fix] several fixes
Diffstat (limited to 'searx/engines/flickr.py')
-rwxr-xr-x | searx/engines/flickr.py | 11 |
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 |