diff options
author | Léon Tiekötter <leon@tiekoetter.com> | 2022-01-30 15:59:58 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-01-30 19:48:40 +0100 |
commit | a6673a1a94b4f9594de785e3fbe23f670bac2d4c (patch) | |
tree | 0843e0995bf89680f0aa7aca654f0fe96333b8e5 /searx/engines/www1x.py | |
parent | 2a6d84dab5fa22a98718afa7450c7a35b987e9c1 (diff) | |
download | searxng-a6673a1a94b4f9594de785e3fbe23f670bac2d4c.tar.gz searxng-a6673a1a94b4f9594de785e3fbe23f670bac2d4c.zip |
[fix] 1x engine
1x changed the XML result layout.
Diffstat (limited to 'searx/engines/www1x.py')
-rw-r--r-- | searx/engines/www1x.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/searx/engines/www1x.py b/searx/engines/www1x.py index f6b82944d..a7ec06f18 100644 --- a/searx/engines/www1x.py +++ b/searx/engines/www1x.py @@ -1,10 +1,12 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - 1x (Images) +# lint: pylint +"""1x (Images) + """ -from lxml import html, etree from urllib.parse import urlencode, urljoin +from lxml import html, etree + from searx.utils import extract_text, eval_xpath_list, eval_xpath_getindex # about @@ -38,13 +40,14 @@ def request(query, params): def response(resp): results = [] xmldom = etree.fromstring(resp.content) - xmlsearchresult = eval_xpath_getindex(xmldom, '//searchresult', 0) + xmlsearchresult = eval_xpath_getindex(xmldom, '//data', 0) dom = html.fragment_fromstring(xmlsearchresult.text, create_parent='div') - for link in eval_xpath_list(dom, '/div/table/tr/td/div[2]//a'): + for link in eval_xpath_list(dom, '//a'): url = urljoin(base_url, link.attrib.get('href')) title = extract_text(link) - thumbnail_src = urljoin(gallery_url, eval_xpath_getindex(link, './/img', 0).attrib['src']) - + thumbnail_src = urljoin( + gallery_url, (eval_xpath_getindex(link, './/img', 0).attrib['src']).replace(base_url, '') + ) # append result results.append( { |