[fix] several fixes

This commit is contained in:
asciimoo 2013-10-18 09:35:29 +02:00
parent 3b85089e77
commit b1a996ef4a

View File

@ -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