.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
pixiv.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Pixiv (images)"""
3
4
from
urllib.parse
import
urlencode
5
import
random
6
7
# Engine metadata
8
about = {
9
"website"
:
'https://www.pixiv.net/'
,
10
"wikidata_id"
:
'Q306956'
,
11
"official_api_documentation"
:
None
,
12
"use_official_api"
:
False
,
13
"require_api_key"
:
False
,
14
"results"
:
'JSON'
,
15
}
16
17
# Engine configuration
18
paging =
True
19
categories = [
'images'
]
20
21
# Search URL
22
base_url =
"https://www.pixiv.net/ajax/search/illustrations"
23
pixiv_image_proxies: list = []
24
25
26
def
request
(query, params):
27
query_params = {
28
"word"
: query,
29
"order"
:
"date_d"
,
30
"mode"
:
"all"
,
31
"p"
: params[
"pageno"
],
32
"s_mode"
:
"s_tag_full"
,
33
"type"
:
"illust_and_ugoira"
,
34
"lang"
:
"en"
,
35
}
36
37
params[
"url"
] = f
"{base_url}/{query}?{urlencode(query_params)}"
38
39
return
params
40
41
42
def
response
(resp):
43
results = []
44
data = resp.json()
45
46
for
item
in
data[
"body"
][
"illust"
][
"data"
]:
47
48
image_url = item[
"url"
]
49
pixiv_proxy = random.choice(pixiv_image_proxies)
50
proxy_image_url = image_url.replace(
"https://i.pximg.net"
, pixiv_proxy)
51
proxy_full_image_url = (
52
proxy_image_url.replace(
"/c/250x250_80_a2/"
,
"/"
)
53
.replace(
"_square1200.jpg"
,
"_master1200.jpg"
)
54
.replace(
"custom-thumb"
,
"img-master"
)
55
.replace(
"_custom1200.jpg"
,
"_master1200.jpg"
)
56
)
57
58
results.append(
59
{
60
"title"
: item.get(
"title"
),
61
"url"
: proxy_full_image_url,
62
'content'
: item.get(
'alt'
),
63
"author"
: f
"{item.get('userName')} (ID: {item.get('userId')})"
,
64
"img_src"
: proxy_full_image_url,
65
"thumbnail_src"
: proxy_image_url,
66
"source"
:
'pixiv.net'
,
67
"template"
:
"images.html"
,
68
}
69
)
70
71
return
results
searx.engines.pixiv.response
response(resp)
Definition
pixiv.py:42
searx.engines.pixiv.request
request(query, params)
Definition
pixiv.py:26
searxng
searx
engines
pixiv.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0