40def response(resp):
41 results = []
42 dom = html.fromstring(resp.text)
43
44 search_res = eval_xpath_list(dom, '//table[contains(@class, "data")]//tr[descendant::a]', None)
45 if search_res is None:
46 return []
47
48 for tag in search_res[1:]:
49 result = {'template': 'torrent.html'}
50 url = eval_xpath_getindex(tag, './/a[contains(@class, "cellMainLink")]/@href', 0, None)
51 result['url'] = resp.search_params['base_url'] + url
52 result['title'] = extract_text(eval_xpath(tag, './/a[contains(@class, "cellMainLink")]'))
53 result['content'] = extract_text(eval_xpath(tag, './/span[@class="font11px lightgrey block"]'))
54 result['seed'] = int_or_zero(extract_text(eval_xpath(tag, './/td[contains(@class, "green")]')))
55 result['leech'] = int_or_zero(extract_text(eval_xpath(tag, './/td[contains(@class, "red")]')))
56 result['filesize'] = extract_text(eval_xpath(tag, './/td[contains(@class, "nobr")]'))
57
58 results.append(result)
59
60
61 return sorted(results, key=itemgetter('seed'), reverse=True)