diff options
author | Alexandre Flament <alex@al-f.net> | 2020-11-26 15:49:33 +0100 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-12-03 10:22:48 +0100 |
commit | ad72803ed98760b2a95690dea3b95eacc670427c (patch) | |
tree | 7e8515b6c4752baedb5e80588c9041bc72cdeb04 /searx/engines/1337x.py | |
parent | de887c6347db4c810f7d1e11c77633340d4e2fbd (diff) | |
download | searxng-ad72803ed98760b2a95690dea3b95eacc670427c.tar.gz searxng-ad72803ed98760b2a95690dea3b95eacc670427c.zip |
[mod] xpath, 1337x, acgsou, apkmirror, archlinux, arxiv: use eval_xpath_* functions
Diffstat (limited to 'searx/engines/1337x.py')
-rw-r--r-- | searx/engines/1337x.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/searx/engines/1337x.py b/searx/engines/1337x.py index 9e045bc51..18478876a 100644 --- a/searx/engines/1337x.py +++ b/searx/engines/1337x.py @@ -1,6 +1,6 @@ from urllib.parse import quote, urljoin from lxml import html -from searx.utils import extract_text, get_torrent_size +from searx.utils import extract_text, get_torrent_size, eval_xpath, eval_xpath_list, eval_xpath_getindex url = 'https://1337x.to/' @@ -20,12 +20,12 @@ def response(resp): dom = html.fromstring(resp.text) - for result in dom.xpath('//table[contains(@class, "table-list")]/tbody//tr'): - href = urljoin(url, result.xpath('./td[contains(@class, "name")]/a[2]/@href')[0]) - title = extract_text(result.xpath('./td[contains(@class, "name")]/a[2]')) - seed = extract_text(result.xpath('.//td[contains(@class, "seeds")]')) - leech = extract_text(result.xpath('.//td[contains(@class, "leeches")]')) - filesize_info = extract_text(result.xpath('.//td[contains(@class, "size")]/text()')) + for result in eval_xpath_list(dom, '//table[contains(@class, "table-list")]/tbody//tr'): + href = urljoin(url, eval_xpath_getindex(result, './td[contains(@class, "name")]/a[2]/@href', 0)) + title = extract_text(eval_xpath(result, './td[contains(@class, "name")]/a[2]')) + seed = extract_text(eval_xpath(result, './/td[contains(@class, "seeds")]')) + leech = extract_text(eval_xpath(result, './/td[contains(@class, "leeches")]')) + filesize_info = extract_text(eval_xpath(result, './/td[contains(@class, "size")]/text()')) filesize, filesize_multiplier = filesize_info.split() filesize = get_torrent_size(filesize, filesize_multiplier) |