Browse Source

Add 1337x.to engine

jcherqui 8 years ago
parent
commit
0549fb40d2
2 changed files with 33 additions and 0 deletions
  1. 29
    0
      searx/engines/1337x.py
  2. 4
    0
      searx/settings.yml

+ 29
- 0
searx/engines/1337x.py View File

@@ -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

+ 4
- 0
searx/settings.yml View File

@@ -588,6 +588,10 @@ engines:
588 588
     timeout : 10.0
589 589
     disabled : True
590 590
 
591
+  - name : 1337x
592
+    engine : 1337x
593
+    shortcut : 1337x
594
+    disabled : False
591 595
 
592 596
 #The blekko technology and team have joined IBM Watson! -> https://blekko.com/
593 597
 #  - name : blekko images