48 dom = html.fromstring(resp.text)
50 for result
in eval_xpath(dom,
'//li[contains(@class, "search-result")]'):
51 torrentfile = eval_xpath_getindex(result,
'.//a[contains(@class, "dl-torrent")]/@href', 0,
None)
52 magnet = eval_xpath_getindex(result,
'.//a[contains(@class, "dl-magnet")]/@href', 0,
None)
53 if torrentfile
is None or magnet
is None:
55 title = eval_xpath_getindex(result,
'.//h5[contains(@class, "title")]', 0,
None)
56 url = eval_xpath_getindex(result,
'.//h5[contains(@class, "title")]/a/@href', 0,
None)
57 categ = eval_xpath(result,
'.//a[contains(@class, "category")]')
58 stats = eval_xpath_list(result,
'.//div[contains(@class, "stats")]/div', min_len=5)
61 'seed': extract_text(stats[3]),
62 'leech': extract_text(stats[2]),
63 'title': extract_text(title),
64 'url': resp.search_params[
'base_url'] + url,
65 'filesize': extract_text(stats[1]),
67 'torrentfile': torrentfile,
68 'metadata': extract_text(categ),
69 'template':
"torrent.html",
73 params[
'publishedDate'] = datetime.strptime(extract_text(stats[4]),
'%b %d, %Y')
77 results.append(params)