.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
pinterest.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Pinterest (images)
3
"""
4
5
from
json
import
dumps
6
7
about = {
8
"website"
:
'https://www.pinterest.com/'
,
9
"wikidata_id"
:
'Q255381'
,
10
"official_api_documentation"
:
'https://developers.pinterest.com/docs/api/v5/'
,
11
"use_official_api"
:
False
,
12
"require_api_key"
:
False
,
13
"results"
:
'JSON'
,
14
}
15
16
categories = [
'images'
]
17
paging =
True
18
19
base_url =
'https://www.pinterest.com'
20
21
22
def
request
(query, params):
23
args = {
24
'options'
: {
25
'query'
: query,
26
'bookmarks'
: [params[
'engine_data'
].get(
'bookmark'
,
''
)],
27
},
28
'context'
: {},
29
}
30
params[
'url'
] = f
"{base_url}/resource/BaseSearchResource/get/?data={dumps(args)}"
31
32
return
params
33
34
35
def
response
(resp):
36
results = []
37
38
json_resp = resp.json()
39
40
results.append(
41
{
42
'engine_data'
: json_resp[
'resource_response'
][
'bookmark'
],
43
# it's called bookmark by pinterest, but it's rather a nextpage
44
# parameter to get the next results
45
'key'
:
'bookmark'
,
46
}
47
)
48
49
for
result
in
json_resp[
'resource_response'
][
'data'
][
'results'
]:
50
51
if
result[
'type'
] ==
'story'
:
52
continue
53
54
results.append(
55
{
56
'template'
:
'images.html'
,
57
'url'
: result[
'link'
]
or
f
"{base_url}/pin/{result['id']}/"
,
58
'title'
: result.get(
'title'
)
or
result.get(
'grid_title'
),
59
'content'
: (result.get(
'rich_summary'
)
or
{}).get(
'display_description'
)
or
""
,
60
'img_src'
: result[
'images'
][
'orig'
][
'url'
],
61
'thumbnail_src'
: result[
'images'
][
'236x'
][
'url'
],
62
'source'
: (result.get(
'rich_summary'
)
or
{}).get(
'site_name'
),
63
}
64
)
65
66
return
results
searx.engines.pinterest.response
response(resp)
Definition
pinterest.py:35
searx.engines.pinterest.request
request(query, params)
Definition
pinterest.py:22
searxng
searx
engines
pinterest.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0