@@ -6,13 +6,14 @@
66# @using-api no (TODO, rewrite to api)
77# @results HTML
88# @stable no (HTML can change)
9−# @parse url, title, thumbnail, img_src
9+# @parse url, title, thumbnail_src, img_src
1010#
1111# @todo rewrite to api
1212
1313from urllib import urlencode
1414from urlparse import urljoin
1515from lxml import html
16+import re
1617
1718# engine dependent config
1819categories = ['images']
@@ -43,18 +44,22 @@ def response(resp):
4344
4445 dom = html.fromstring(resp.text)
4546
47+ regex = re.compile('\/200H\/')
48+
4649 # parse results
4750 for result in dom.xpath('//div[contains(@class, "tt-a tt-fh")]'):
4851 link = result.xpath('.//a[contains(@class, "thumb")]')[0]
4952 url = urljoin(base_url, link.attrib.get('href'))
5053 title_links = result.xpath('.//span[@class="details"]//a[contains(@class, "t")]') # noqa
5154 title = ''.join(title_links[0].xpath('.//text()'))
52− img_src = link.xpath('.//img')[0].attrib['src']
55+ thumbnail_src = link.xpath('.//img')[0].attrib['src']
56+ img_src = regex.sub('/', thumbnail_src)
5357
5458 # append result
5559 results.append({'url': url,
5660 'title': title,
5761 'img_src': img_src,
62+ 'thumbnail_src': thumbnail_src,
5863 'template': 'images.html'})
5964
6065 # return results