.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
bpb.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""BPB refers to ``Bundeszentrale für poltische Bildung``, which is a German
3
governmental institution aiming to reduce misinformation by providing resources
4
about politics and history.
5
"""
6
7
from
datetime
import
datetime
8
from
urllib.parse
import
urlencode
9
10
about = {
11
'website'
:
"https://www.bpb.de"
,
12
'official_api_documentation'
:
None
,
13
'use_official_api'
:
False
,
14
'require_api_key'
:
False
,
15
'results'
:
'JSON'
,
16
'language'
:
'de'
,
17
}
18
19
paging =
True
20
categories = [
'general'
]
21
22
23
base_url =
"https://www.bpb.de"
24
25
26
def
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
37
def
response
(resp):
38
results = []
39
40
json_resp = resp.json()
41
42
for
result
in
json_resp[
'teaser'
]:
43
thumbnail =
None
44
if
result[
'teaser'
][
'image'
]:
45
thumbnail = 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
'thumbnail'
: thumbnail,
62
'publishedDate'
: publishedDate,
63
'metadata'
: metadata,
64
}
65
)
66
67
return
results
searx.engines.bpb.response
response(resp)
Definition
bpb.py:37
searx.engines.bpb.request
request(query, params)
Definition
bpb.py:26
searxng
searx
engines
bpb.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0