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

Functions

 request (query, params)
 
EngineResults response (resp)
 

Variables

str engine_type = 'online'
 
bool language_support = False
 
list categories = ['news']
 
bool paging = True
 
int page_size = 12
 
str base_url = 'https://www.ansa.it'
 
bool time_range_support = True
 
dict time_range_args
 
str search_api = 'https://www.ansa.it/ricerca/ansait/search.shtml?'
 
dict about
 

Detailed Description

Engine for Ansa, Italy's oldest news agency.

To use this engine add the following entry to your engines
list in ``settings.yml``:

.. code:: yaml

  - name: ansa
    engine: ansa
    shortcut: ans
    disabled: false

Function Documentation

◆ request()

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

Definition at line 49 of file ansa.py.

49def request(query, params):
50 query_params = {
51 'any': query,
52 'start': (params['pageno'] - 1) * page_size,
53 'sort': "data:desc",
54 }
55
56 if params['time_range']:
57 query_params['periodo'] = time_range_args.get(params['time_range'])
58
59 params['url'] = search_api + urlencode(query_params)
60 return params
61
62

◆ response()

EngineResults searx.engines.ansa.response ( resp)

Definition at line 63 of file ansa.py.

63def response(resp) -> EngineResults:
64 res = EngineResults()
65 doc = html.fromstring(resp.text)
66
67 for result in eval_xpath_list(doc, "//div[@class='article']"):
68
69 res_obj = MainResult(
70 title=extract_text(eval_xpath(result, "./div[@class='content']/h2[@class='title']/a")),
71 content=extract_text(eval_xpath(result, "./div[@class='content']/div[@class='text']")),
72 url=base_url + extract_text(eval_xpath(result, "./div[@class='content']/h2[@class='title']/a/@href")),
73 )
74
75 thumbnail = extract_text(eval_xpath(result, "./div[@class='image']/a/img/@src"))
76 if thumbnail:
77 res_obj.thumbnail = base_url + thumbnail
78
79 res.append(res_obj)
80
81 return res

Variable Documentation

◆ about

dict searx.engines.ansa.about
Initial value:
1= {
2 'website': 'https://www.ansa.it',
3 'wikidata_id': 'Q392934',
4 'official_api_documentation': None,
5 'use_official_api': False,
6 'require_api_key': False,
7 'results': 'HTML',
8 'language': 'it',
9}

Definition at line 38 of file ansa.py.

◆ base_url

str searx.engines.ansa.base_url = 'https://www.ansa.it'

Definition at line 26 of file ansa.py.

◆ categories

list searx.engines.ansa.categories = ['news']

Definition at line 23 of file ansa.py.

◆ engine_type

str searx.engines.ansa.engine_type = 'online'

Definition at line 21 of file ansa.py.

◆ language_support

bool searx.engines.ansa.language_support = False

Definition at line 22 of file ansa.py.

◆ page_size

int searx.engines.ansa.page_size = 12

Definition at line 25 of file ansa.py.

◆ paging

bool searx.engines.ansa.paging = True

Definition at line 24 of file ansa.py.

◆ search_api

str searx.engines.ansa.search_api = 'https://www.ansa.it/ricerca/ansait/search.shtml?'

Definition at line 36 of file ansa.py.

◆ time_range_args

dict searx.engines.ansa.time_range_args
Initial value:
1= {
2 'day': 1,
3 'week': 7,
4 'month': 31,
5 'year': 365,
6}

Definition at line 29 of file ansa.py.

◆ time_range_support

bool searx.engines.ansa.time_range_support = True

Definition at line 28 of file ansa.py.