43 dom = html.fromstring(resp.text)
44 rows = dom.xpath(
'//table[@class="listing"]//tr[contains(@class, "category_0")]')
48 if len(rows) == 0
or len(rows) % 2 != 0:
52 size_re = re.compile(
r'[\d.]+(T|G|M)?B', re.IGNORECASE)
55 for i
in range(0, len(rows), 2):
59 links = name_row.xpath(
'./td[@class="desc-top"]/a')
60 params = {
'template':
'torrent.html',
'url': links[-1].attrib.get(
'href'),
'title': extract_text(links[-1])}
64 magnet = links[0].attrib.get(
'href')
65 if magnet.startswith(
'magnet'):
67 params[
'magnetlink'] = magnet
70 info_row = rows[i + 1]
71 desc = extract_text(info_row.xpath(
'./td[@class="desc-bot"]')[0])
72 for item
in desc.split(
'|'):
74 if item.startswith(
'Size:'):
76 params[
'filesize'] = size_re.search(item).group()
79 elif item.startswith(
'Date:'):
82 date = datetime.strptime(item,
'Date: %Y-%m-%d %H:%M UTC')
83 params[
'publishedDate'] = date
86 elif item.startswith(
'Comment:'):
87 params[
'content'] = item
88 stats = info_row.xpath(
'./td[@class="stats"]/span')
91 params[
'seed'] = int_or_zero(extract_text(stats[0]))
92 params[
'leech'] = int_or_zero(extract_text(stats[1]))
94 results.append(params)