From 78f5300830e0e897fd344f9c9022e556aae39fe9 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 26 Nov 2024 15:30:32 +0100 Subject: [PATCH] [chore] drop sjp engine: WEB side has changed a long time ago The WEB page (PL only) has changed and there is now also a kind of CAPTCHA. There is currently no possibility to restore the function of this engine. Signed-off-by: Markus Heiser --- searx/engines/sjp.py | 98 -------------------------------------------- searx/settings.yml | 6 --- 2 files changed, 104 deletions(-) delete mode 100644 searx/engines/sjp.py diff --git a/searx/engines/sjp.py b/searx/engines/sjp.py deleted file mode 100644 index 639420095..000000000 --- a/searx/engines/sjp.py +++ /dev/null @@ -1,98 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -"""Słownik Języka Polskiego - -Dictionary of the polish language from PWN (sjp.pwn) -""" - -from lxml.html import fromstring -from searx import logger -from searx.utils import extract_text -from searx.network import raise_for_httperror - -logger = logger.getChild('sjp engine') - -# about -about = { - "website": 'https://sjp.pwn.pl', - "wikidata_id": 'Q55117369', - "official_api_documentation": None, - "use_official_api": False, - "require_api_key": False, - "results": 'HTML', - "language": 'pl', -} - -categories = ['dictionaries'] -paging = False - -URL = 'https://sjp.pwn.pl' -SEARCH_URL = URL + '/szukaj/{query}.html' - -word_xpath = '//div[@class="query"]' -dict_xpath = [ - '//div[@class="wyniki sjp-so-wyniki sjp-so-anchor"]', - '//div[@class="wyniki sjp-wyniki sjp-anchor"]', - '//div[@class="wyniki sjp-doroszewski-wyniki sjp-doroszewski-anchor"]', -] - - -def request(query, params): - params['url'] = SEARCH_URL.format(query=query) - logger.debug(f"query_url --> {params['url']}") - return params - - -def response(resp): - results = [] - - raise_for_httperror(resp) - dom = fromstring(resp.text) - word = extract_text(dom.xpath(word_xpath)) - - definitions = [] - - for dict_src in dict_xpath: - for src in dom.xpath(dict_src): - src_text = extract_text(src.xpath('.//span[@class="entry-head-title"]/text()')).strip() - - src_defs = [] - for def_item in src.xpath('.//div[contains(@class, "ribbon-element")]'): - if def_item.xpath('./div[@class="znacz"]'): - sub_defs = [] - for def_sub_item in def_item.xpath('./div[@class="znacz"]'): - def_sub_text = extract_text(def_sub_item).lstrip('0123456789. ') - sub_defs.append(def_sub_text) - src_defs.append((word, sub_defs)) - else: - def_text = extract_text(def_item).strip() - def_link = def_item.xpath('./span/a/@href') - if 'doroszewski' in def_link[0]: - def_text = f"{def_text}" - src_defs.append((def_text, '')) - - definitions.append((src_text, src_defs)) - - if not definitions: - return results - - infobox = '' - for src in definitions: - infobox += f"
{src[0]}" - infobox += "
    " - for def_text, sub_def in src[1]: - infobox += f"
  • {def_text}
  • " - if sub_def: - infobox += "
      " - for sub_def_text in sub_def: - infobox += f"
    1. {sub_def_text}
    2. " - infobox += "
    " - infobox += "
" - - results.append( - { - 'infobox': word, - 'content': infobox, - } - ) - - return results diff --git a/searx/settings.yml b/searx/settings.yml index dd981e5e9..0baa60770 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -2277,12 +2277,6 @@ engines: seekr_category: videos disabled: true - - name: sjp.pwn - engine: sjp - shortcut: sjp - timeout: 5.0 - disabled: true - - name: stract engine: stract shortcut: str