|
@@ -4,26 +4,25 @@ from urllib import quote
|
4
|
4
|
from lxml import html
|
5
|
5
|
from urlparse import urljoin
|
6
|
6
|
|
7
|
|
-categories = ['img']
|
|
7
|
+categories = ['images']
|
8
|
8
|
|
9
|
9
|
base_url = 'https://secure.flickr.com/'
|
10
|
10
|
search_url = base_url+'search/?q='
|
11
|
11
|
|
12
|
12
|
def request(query, params):
|
13
|
13
|
global search_url
|
14
|
|
- print 'qqwerqwerqwerqwer'
|
15
|
14
|
query = quote(query.replace(' ', '+'), safe='+')
|
16
|
15
|
params['url'] = search_url + query
|
17
|
16
|
return params
|
18
|
17
|
|
19
|
18
|
def response(resp):
|
20
|
19
|
global base_url
|
21
|
|
- print 'asdfasdfasdf'
|
22
|
20
|
results = []
|
23
|
21
|
dom = html.fromstring(resp.text)
|
24
|
|
- for result in dom.xpath('//#thumbnails//a'):
|
|
22
|
+ for result in dom.xpath('//div[@id="thumbnails"]//a[@class="rapidnofollow photo-click" and @data-track="photo-click"]'):
|
25
|
23
|
url = urljoin(base_url, result.attrib.get('href'))
|
26
|
|
- title = result.xpath('./img')[0].attrib.get('alt')
|
27
|
|
- content = "<img src='%s'></img>" % result.xpath('./img')[0].attrib.get('src')
|
|
24
|
+ img = result.xpath('.//img')[0]
|
|
25
|
+ title = img.attrib.get('alt', '')
|
|
26
|
+ content = '<img src="%s" alt="%s" />' % (img.attrib.get('data-defer-src', ''), title)
|
28
|
27
|
results.append({'url': url, 'title': title, 'content': content})
|
29
|
28
|
return results
|