.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
artic.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""The Art Institute of Chicago
3
4
Explore thousands of artworks from The Art Institute of Chicago.
5
6
* https://artic.edu
7
8
"""
9
10
from
json
import
loads
11
from
urllib.parse
import
urlencode
12
13
about = {
14
"website"
:
'https://www.artic.edu'
,
15
"wikidata_id"
:
'Q239303'
,
16
"official_api_documentation"
:
'http://api.artic.edu/docs/'
,
17
"use_official_api"
:
True
,
18
"require_api_key"
:
False
,
19
"results"
:
'JSON'
,
20
}
21
22
categories = [
'images'
]
23
paging =
True
24
nb_per_page = 20
25
26
search_api =
'https://api.artic.edu/api/v1/artworks/search?'
27
image_api =
'https://www.artic.edu/iiif/2/'
28
29
30
def
request
(query, params):
31
32
args = urlencode(
33
{
34
'q'
: query,
35
'page'
: params[
'pageno'
],
36
'fields'
:
'id,title,artist_display,medium_display,image_id,date_display,dimensions,artist_titles'
,
37
'limit'
: nb_per_page,
38
}
39
)
40
params[
'url'
] = search_api + args
41
42
logger.debug(
"query_url --> %s"
, params[
'url'
])
43
return
params
44
45
46
def
response
(resp):
47
48
results = []
49
json_data = loads(resp.text)
50
51
for
result
in
json_data[
'data'
]:
52
53
if
not
result[
'image_id'
]:
54
continue
55
56
results.append(
57
{
58
'url'
:
'https://artic.edu/artworks/%(id)s'
% result,
59
'title'
: result[
'title'
] +
" (%(date_display)s) // %(artist_display)s"
% result,
60
'content'
:
"%(medium_display)s // %(dimensions)s"
% result,
61
'author'
:
', '
.join(result[
'artist_titles'
]),
62
'img_src'
: image_api +
'/%(image_id)s/full/843,/0/default.jpg'
% result,
63
'template'
:
'images.html'
,
64
}
65
)
66
67
return
results
searx.engines.artic.request
request(query, params)
Definition
artic.py:30
searx.engines.artic.response
response(resp)
Definition
artic.py:46
searxng
searx
engines
artic.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0