.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
1337x.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2# pylint: disable=invalid-name
3"""1337x
4
5"""
6
7from urllib.parse import quote, urljoin
8from lxml import html
9from searx.utils import extract_text, eval_xpath, eval_xpath_list, eval_xpath_getindex
10
11# about
12about = {
13 "website": 'https://1337x.to/',
14 "wikidata_id": 'Q28134166',
15 "official_api_documentation": None,
16 "use_official_api": False,
17 "require_api_key": False,
18 "results": 'HTML',
19}
20
21url = 'https://1337x.to/'
22search_url = url + 'search/{search_term}/{pageno}/'
23categories = ['files']
24paging = True
25
26
27def request(query, params):
28 params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno'])
29
30 return params
31
32
33def response(resp):
34 results = []
35
36 dom = html.fromstring(resp.text)
37
38 for result in eval_xpath_list(dom, '//table[contains(@class, "table-list")]/tbody//tr'):
39 href = urljoin(url, eval_xpath_getindex(result, './td[contains(@class, "name")]/a[2]/@href', 0))
40 title = extract_text(eval_xpath(result, './td[contains(@class, "name")]/a[2]'))
41 seed = extract_text(eval_xpath(result, './/td[contains(@class, "seeds")]'))
42 leech = extract_text(eval_xpath(result, './/td[contains(@class, "leeches")]'))
43 filesize = extract_text(eval_xpath(result, './/td[contains(@class, "size")]/text()'))
44
45 results.append(
46 {
47 'url': href,
48 'title': title,
49 'seed': seed,
50 'leech': leech,
51 'filesize': filesize,
52 'template': 'torrent.html',
53 }
54 )
55
56 return results
request(query, params)
Definition 1337x.py:27