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] engine: add engine for italian online newspaper "il post"
Tommaso Colella5daa4f0460c9
diff --git a/AUTHORS.rst b/AUTHORS.rstindex adf4eb7d9..8de19911d 100644--- a/AUTHORS.rst+++ b/AUTHORS.rst@@ -176,3 +176,4 @@ features or generally made searx better:- Patrick Evans `https://github.com/holysoles`- Daniel Mowitz `<https://daniel.mowitz.rocks>`- `Bearz314 <https://github.com/bearz314>`_+- Tommaso Colella `<https://github.com/gioleppe>`diff --git a/searx/engines/il_post.py b/searx/engines/il_post.pynew file mode 100644index 000000000..1215c4dad--- /dev/null+++ b/searx/engines/il_post.py@@ -0,0 +1,71 @@+# SPDX-License-Identifier: AGPL-3.0-or-later+"""Engine for Il Post, a largely independent online Italian newspaper.++To use this engine add the following entry to your engines+list in ``settings.yml``:++.. code:: yaml++ - name: il post+ engine: il_post+ shortcut: pst+ disabled: false++"""++from urllib.parse import urlencode+from searx.result_types import EngineResults++engine_type = "online"+language_support = False+categories = ["news"]+paging = True+page_size = 10++time_range_support = True+time_range_args = {"month": "pub_date:ultimi_30_giorni", "year": "pub_date:ultimo_anno"}++search_api = "https://api.ilpost.org/search/api/site_search/?"++about = {+ "website": "https://www.ilpost.it",+ "wikidata_id": "Q3792882",+ "official_api_documentation": None,+ "use_official_api": True,+ "require_api_key": False,+ "results": "JSON",+ "language": "it",+}+++def request(query, params):+ query_params = {+ "qs": query,+ "pg": params["pageno"],+ "sort": "date_d",+ "filters": "ctype:articoli",+ }++ if params["time_range"]:+ if params["time_range"] not in time_range_args:+ return None+ query_params["filters"] += f";{time_range_args.get(params['time_range'], 'pub_date:da_sempre')}"+ params["url"] = search_api + urlencode(query_params)+ return params+++def response(resp) -> EngineResults:+ res = EngineResults()+ json_data = resp.json()++ for result in json_data["docs"]:+ res.add(+ res.types.MainResult(+ url=result["link"],+ title=result["title"],+ content=result.get("summary", ""),+ thumbnail=result.get("image"),+ )+ )++ return resdiff --git a/searx/settings.yml b/searx/settings.ymlindex 55893f8a1..a08e2a625 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -1126,6 +1126,11 @@ engines:require_api_key: falseresults: JSON+ - name: il post+ engine: il_post+ shortcut: pst+ disabled: true+- name: imdbengine: imdbshortcut: imdb