|
@@ -0,0 +1,29 @@
|
|
1
|
+from urllib import quote
|
|
2
|
+from lxml import html
|
|
3
|
+from searx.engines.xpath import extract_text
|
|
4
|
+from urlparse import urljoin
|
|
5
|
+
|
|
6
|
+url = 'https://1337x.to/'
|
|
7
|
+search_url = url + 'search/{search_term}/{pageno}/'
|
|
8
|
+categories = ['videos', 'music', 'files']
|
|
9
|
+paging = True
|
|
10
|
+
|
|
11
|
+def request(query, params):
|
|
12
|
+ params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno'])
|
|
13
|
+
|
|
14
|
+ return params
|
|
15
|
+
|
|
16
|
+def response(resp):
|
|
17
|
+ results = []
|
|
18
|
+
|
|
19
|
+ dom = html.fromstring(resp.text)
|
|
20
|
+
|
|
21
|
+ for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'):
|
|
22
|
+ href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0])
|
|
23
|
+ title = extract_text(result.xpath('./td[contains(@class, "name")]/a[2]'))
|
|
24
|
+
|
|
25
|
+ results.append({'url': href,
|
|
26
|
+ 'title': title,
|
|
27
|
+ 'content': ''})
|
|
28
|
+
|
|
29
|
+ return results
|