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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
bool paging = True
 
list categories = ['general']
 
str base_url = "https://www.bpb.de"
 

Detailed Description

BPB refers to ``Bundeszentrale für poltische Bildung``, which is a German
governmental institution aiming to reduce misinformation by providing resources
about politics and history.

Function Documentation

◆ request()

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

Definition at line 26 of file bpb.py.

26def request(query, params):
27 args = {
28 'query[term]': query,
29 'page': params['pageno'] - 1,
30 'sort[direction]': 'descending',
31 'payload[nid]': 65350,
32 }
33 params['url'] = f"{base_url}/bpbapi/filter/search?{urlencode(args)}"
34 return params
35
36

◆ response()

searx.engines.bpb.response ( resp)

Definition at line 37 of file bpb.py.

37def response(resp):
38 results = []
39
40 json_resp = resp.json()
41
42 for result in json_resp['teaser']:
43 img_src = None
44 if result['teaser']['image']:
45 img_src = base_url + result['teaser']['image']['sources'][-1]['url']
46
47 metadata = result['extension']['overline']
48 authors = ', '.join(author['name'] for author in result['extension'].get('authors', []))
49 if authors:
50 metadata += f" | {authors}"
51
52 publishedDate = None
53 if result['extension'].get('publishingDate'):
54 publishedDate = datetime.utcfromtimestamp(result['extension']['publishingDate'])
55
56 results.append(
57 {
58 'url': base_url + result['teaser']['link']['url'],
59 'title': result['teaser']['title'],
60 'content': result['teaser']['text'],
61 'img_src': img_src,
62 'publishedDate': publishedDate,
63 'metadata': metadata,
64 }
65 )
66
67 return results

Variable Documentation

◆ about

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

Definition at line 10 of file bpb.py.

◆ base_url

str searx.engines.bpb.base_url = "https://www.bpb.de"

Definition at line 23 of file bpb.py.

◆ categories

list searx.engines.bpb.categories = ['general']

Definition at line 20 of file bpb.py.

◆ paging

bool searx.engines.bpb.paging = True

Definition at line 19 of file bpb.py.