35def response(resp):
36 dom = html.fromstring(resp.text)
37 search_res = dom.xpath('.//td[@class="x-item"]')
38
39 if not search_res:
40 return []
41
42 results = []
43 for result in search_res:
44 url = urljoin(URL, result.xpath('.//a[@title]/@href')[0])
45 title = extract_text(result.xpath('.//a[@title]'))
46 content = extract_text(result.xpath('.//div[@class="files"]'))
47 files_data = extract_text(result.xpath('.//div[@class="tail"]')).split()
48 filesize = f"{files_data[FILESIZE]} {files_data[FILESIZE_MULTIPLIER]}"
49 magnetlink = result.xpath('.//div[@class="tail"]//a[@class="title"]/@href')[0]
50
51 results.append(
52 {
53 'url': url,
54 'title': title,
55 'content': content,
56 'filesize': filesize,
57 'magnetlink': magnetlink,
58 'seed': 'N/A',
59 'leech': 'N/A',
60 'template': 'torrent.html',
61 }
62 )
63
64 return results