.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.reuters Namespace Reference

Functions

 request (query, params)
 
EngineResults response (resp)
 

Variables

dict about
 
list categories = ["news"]
 
bool time_range_support = True
 
bool paging = True
 
str base_url = "https://www.reuters.com"
 
int results_per_page = 20
 
str sort_order = "relevance"
 
dict time_range_duration_map
 

Detailed Description

Reuters_ (news) is an international news agency.

.. _Reuters: https://www.reuters.com

Configuration
=============

The engine has the following additional settings:

- :py:obj:`sort_order`

.. code:: yaml

   - name: reuters
     engine: reuters
     shortcut: reu
     sort_order: "relevance"


Implementations
===============

Function Documentation

◆ request()

searx.engines.reuters.request ( query,
params )

Definition at line 59 of file reuters.py.

59def request(query, params):
60 args = {
61 "keyword": query,
62 "offset": (params["pageno"] - 1) * results_per_page,
63 "orderby": sort_order,
64 "size": results_per_page,
65 "website": "reuters",
66 }
67 if params["time_range"]:
68 time_diff_days = time_range_duration_map[params["time_range"]]
69 start_date = datetime.now() - timedelta(days=time_diff_days)
70 args["start_date"] = start_date.isoformat()
71
72 params["url"] = f"{base_url}/pf/api/v3/content/fetch/articles-by-search-v2?query={quote_plus(dumps(args))}"
73 return params
74
75

◆ response()

EngineResults searx.engines.reuters.response ( resp)

Definition at line 76 of file reuters.py.

76def response(resp) -> EngineResults:
77 res = EngineResults()
78
79 for result in resp.json().get("result", {}).get("articles", []):
80 res.add(
81 res.types.MainResult(
82 url=base_url + result["canonical_url"],
83 title=result["web"],
84 content=result["description"],
85 thumbnail=result.get("thumbnail", {}).get("url", ""),
86 metadata=result.get("kicker", {}).get("name"),
87 publishedDate=datetime.strptime(result["display_time"], "%Y-%m-%dT%H:%M:%SZ"),
88 )
89 )
90 return res

Variable Documentation

◆ about

dict searx.engines.reuters.about
Initial value:
1= {
2 "website": "https://www.reuters.com",
3 "wikidata_id": "Q130879",
4 "official_api_documentation": None,
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": "JSON",
8}

Definition at line 32 of file reuters.py.

◆ base_url

str searx.engines.reuters.base_url = "https://www.reuters.com"

Definition at line 45 of file reuters.py.

◆ categories

list searx.engines.reuters.categories = ["news"]

Definition at line 41 of file reuters.py.

◆ paging

bool searx.engines.reuters.paging = True

Definition at line 43 of file reuters.py.

◆ results_per_page

int searx.engines.reuters.results_per_page = 20

Definition at line 47 of file reuters.py.

◆ sort_order

str searx.engines.reuters.sort_order = "relevance"

Definition at line 48 of file reuters.py.

◆ time_range_duration_map

dict searx.engines.reuters.time_range_duration_map
Initial value:
1= {
2 "day": 1,
3 "week": 7,
4 "month": 30,
5 "year": 365,
6}

Definition at line 51 of file reuters.py.

◆ time_range_support

bool searx.engines.reuters.time_range_support = True

Definition at line 42 of file reuters.py.