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
[feat] engines: add swisscows news engine
Bnyro465b5229c685
diff --git a/searx/engines/swisscows_news.py b/searx/engines/swisscows_news.pynew file mode 100644index 000000000..4409c831d--- /dev/null+++ b/searx/engines/swisscows_news.py@@ -0,0 +1,71 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+# pylint: disable=invalid-name+"""Swisscows news"""++from datetime import datetime+from urllib.parse import urlencode++import typing as t++from searx.result_types import EngineResults++if t.TYPE_CHECKING:+ from searx.extended_types import SXNG_Response+ from searx.search.processors import OnlineParams+++about = {+ "website": "https://swisscows.com",+ "wikidata_id": "Q22937452",+ "official_api_documentation": None,+ "use_official_api": False,+ "require_api_key": False,+ "results": "JSON",+}+++categories = ["news"]+results_per_page = 20++time_range_support = True+paging = True++base_url = "https://api.swisscows.com"+time_range_map = {"day": "Day", "week": "Week", "month": "Month", "year": "Year"}+++def request(query: str, params: "OnlineParams") -> None:+ freshness = "All"+ if params["time_range"]:+ freshness = time_range_map[params["time_range"]]++ args = {+ "query": query,+ "itemsCount": results_per_page,+ "region": "de-DE",+ "language": "de",+ "offset": (params["pageno"] - 1) * results_per_page,+ "freshness": freshness,+ "sortOrder": "Desc",+ "sortBy": "Created",+ }+ url_path = f"/news/search?{urlencode(args)}"++ params["url"] = base_url + url_path+++def response(resp: "SXNG_Response"):+ res = EngineResults()++ for result in resp.json()["items"]:+ res.add(+ res.types.MainResult(+ url=result["uri"],+ title=result["title"],+ content=result["description"],+ publishedDate=datetime.fromisoformat(result["created"]),+ thumbnail=result.get("og:image"),+ )+ )++ return resdiff --git a/searx/settings.yml b/searx/settings.ymlindex 208f94f06..5f41c57f2 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -2545,6 +2545,11 @@ engines:shortcut: swidisabled: true+ - name: swisscows news+ engine: swisscows_news+ shortcut: swn+ disabled: true+- name: wordnikengine: wordnikshortcut: wnik