@@ -28,14 +28,11 @@ xpath_title = './/td[3]/a[last()]'
28xpath_torrent_links = './/td[3]/a'
28xpath_torrent_links = './/td[3]/a'
29xpath_filesize = './/td[4]/text()'
29xpath_filesize = './/td[4]/text()'
32def request(query, params):
31def request(query, params):
33 query = urlencode({'keyword': query})
32 query = urlencode({'keyword': query})
34 params['url'] = search_url.format(query=query, offset=params['pageno'])
33 params['url'] = search_url.format(query=query, offset=params['pageno'])
35 return params
34 return params
38−# get response from search-request
39def response(resp):
36def response(resp):
40 results = []
37 results = []
41 dom = html.fromstring(resp.text)
38 dom = html.fromstring(resp.text)
@@ -46,23 +43,17 @@ def response(resp):
46 magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
43 magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
47 torrent_link = ""
44 torrent_link = ""
49− # category in which our torrent belongs
51 category = extract_text(result.xpath(xpath_category)[0])
47 category = extract_text(result.xpath(xpath_category)[0])
56 page_a = result.xpath(xpath_title)[0]
51 page_a = result.xpath(xpath_title)[0]
57 title = extract_text(page_a)
52 title = extract_text(page_a)
60 href = base_url + page_a.attrib.get('href')
53 href = base_url + page_a.attrib.get('href')
63 magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
55 magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
65− # let's try to calculate the torrent size
67 filesize_info = result.xpath(xpath_filesize)[0]
58 filesize_info = result.xpath(xpath_filesize)[0]
68 filesize = filesize_info[:-2]
59 filesize = filesize_info[:-2]
@@ -70,16 +61,14 @@ def response(resp):
70 filesize = get_torrent_size(filesize, filesize_multiplier)
61 filesize = get_torrent_size(filesize, filesize_multiplier)
73−
64+ #I didn't add download/seed/leech count since as I figured out they are generated randowmly everytime
74− # content string contains all information not included into template
75 content = 'Category: "{category}".'
65 content = 'Category: "{category}".'
76 content = content.format(category=category)
66 content = content.format(category=category)
78 results.append({'url': href,
68 results.append({'url': href,
79 'title': title,
69 'title': title,
80 'content': content,
70 'content': content,
81 'filesize': filesize,
71 'filesize': filesize,
82 'magnetlink': magnet_link,
72 'magnetlink': magnet_link,
83 'template': 'torrent.html'})
73 'template': 'torrent.html'})
85 return results
74 return results