|
|
|
|
1
|
from urllib import quote
|
1
|
from urllib import quote
|
2
|
from lxml import html
|
2
|
from lxml import html
|
3
|
from searx.engines.xpath import extract_text
|
3
|
from searx.engines.xpath import extract_text
|
|
|
4
|
+from searx.utils import get_torrent_size
|
4
|
from urlparse import urljoin
|
5
|
from urlparse import urljoin
|
5
|
|
6
|
|
6
|
url = 'https://1337x.to/'
|
7
|
url = 'https://1337x.to/'
|
|
|
|
|
23
|
for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'):
|
24
|
for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'):
|
24
|
href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0])
|
25
|
href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0])
|
25
|
title = extract_text(result.xpath('./td[contains(@class, "name")]/a[2]'))
|
26
|
title = extract_text(result.xpath('./td[contains(@class, "name")]/a[2]'))
|
|
|
27
|
+ seed = extract_text(result.xpath('.//td[contains(@class, "seeds")]'))
|
|
|
28
|
+ leech = extract_text(result.xpath('.//td[contains(@class, "leeches")]'))
|
|
|
29
|
+ filesize_info = extract_text(result.xpath('.//td[contains(@class, "size")]/text()'))
|
|
|
30
|
+ filesize, filesize_multiplier = filesize_info.split()
|
|
|
31
|
+ filesize = get_torrent_size(filesize, filesize_multiplier)
|
26
|
|
32
|
|
27
|
results.append({'url': href,
|
33
|
results.append({'url': href,
|
28
|
'title': title,
|
34
|
'title': title,
|
29
|
- 'content': ''})
|
|
|
|
|
35
|
+ 'seed': seed,
|
|
|
36
|
+ 'leech': leech,
|
|
|
37
|
+ 'filesize': filesize,
|
|
|
38
|
+ 'template': 'torrent.html'})
|
30
|
|
39
|
|
31
|
return results
|
40
|
return results
|