41 dom = html.fromstring(resp.text)
43 search_res = dom.xpath(
'//div[@class="one_result"]')
50 for result
in search_res:
51 link = result.xpath(
'.//div[@class="torrent_name"]//a')[0]
52 href = urljoin(url, link.attrib.get(
'href'))
53 title = extract_text(link)
55 excerpt = result.xpath(
'.//div[@class="torrent_excerpt"]')[0]
56 content = html.tostring(excerpt, encoding=
'unicode', method=
'text', with_tail=
False)
57 content = content.strip().replace(
'\n',
' | ')
58 content =
' '.join(content.split())
60 filesize = result.xpath(
'.//span[@class="torrent_size"]/text()')[0]
61 files = (result.xpath(
'.//span[@class="torrent_files"]/text()')
or [
'1'])[0]
69 magnetlink = result.xpath(
'.//div[@class="torrent_magnet"]//a')[0].attrib[
'href']
79 'magnetlink': magnetlink,
80 'template':
'torrent.html',