SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[mod] wordnik: convert to answerer (#4980)
Bnyro6b16a04e7e45
diff --git a/searx/engines/wordnik.py b/searx/engines/wordnik.pyindex 9b048a068..5b2ac5875 100644--- a/searx/engines/wordnik.py+++ b/searx/engines/wordnik.py@@ -1,11 +1,10 @@# SPDX-License-Identifier: AGPL-3.0-or-later-"""Wordnik (general)--"""+"""Wordnik (general)"""from lxml.html import fromstringfrom searx.utils import extract_text-from searx.network import raise_for_httperror++from searx.result_types import EngineResults# aboutabout = {@@ -17,7 +16,7 @@ about = {"results": 'HTML',}-categories = ['general']+categories = ['dictionaries', 'define']paging = False@@ -27,46 +26,23 @@ def request(query, params):def response(resp):- results = []+ results = EngineResults()- raise_for_httperror(resp)dom = fromstring(resp.text)- word = extract_text(dom.xpath('//*[@id="headword"]/text()'))- definitions = []for src in dom.xpath('//*[@id="define"]//h3[@class="source"]'):- src_text = extract_text(src).strip()- if src_text.startswith('from '):- src_text = src_text[5:]-- src_defs = []+ item = results.types.Translations.Item(text="")for def_item in src.xpath('following-sibling::ul[1]/li'):def_abbr = extract_text(def_item.xpath('.//abbr')).strip()def_text = extract_text(def_item).strip()if def_abbr:def_text = def_text[len(def_abbr) :].strip()- src_defs.append((def_abbr, def_text))- definitions.append((src_text, src_defs))-- if not definitions:- return results-- infobox = ''- for src_text, src_defs in definitions:- infobox += f"<small>{src_text}</small>"- infobox += "<ul>"- for def_abbr, def_text in src_defs:- if def_abbr:- def_abbr += ": "- infobox += f"<li><i>{def_abbr}</i> {def_text}</li>"- infobox += "</ul>"+ # use first result as summary+ if not item.text:+ item.text = def_text+ item.definitions.append(def_text)- results.append(- {- 'infobox': word,- 'content': infobox,- }- )+ results.add(results.types.Translations(translations=[item], url=resp.search_params["url"]))return resultsdiff --git a/searx/settings.yml b/searx/settings.ymlindex 1b6739927..38c087689 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -2494,8 +2494,7 @@ engines:- name: wordnikengine: wordnik- shortcut: def- categories: [dictionaries]+ shortcut: wniktimeout: 5.0- name: woxikon.de synonyme