当前位置:网站首页>[pyhton practice] - batch [Dragon Boat Festival] poster Download
[pyhton practice] - batch [Dragon Boat Festival] poster Download
2022-06-09 10:43:00 【Rattenking】
1. Choose a website to download posters
Take the draft design website as an example :
2. View the poster list API
Webpage —> Right mouse button —> Check 【 Click on network, View page requests 】

Find the data loaded api Methods , Slide the page down to the bottom , Click on page two , Find the interface to load the list , The interface of this website is 【https://www.gaoding.com/api/v3/cp/template-centers/v2/recommend-templates】
3. View request parameters
Click the current interface , Click on payload, You can find the request parameters of the interface !
4. Check the request header
Click the current interface , Click on headers, You can find the request header of the interface !

5. The application needs to use the library to import
import requests,json,time,random,os
6. Get the interface and parameter configuration of the list
url = 'https://www.gaoding.com/api/v3/cp/template-centers/v2/recommend-templates'
data = {
"page_num": 1,
"page_size": 50,
"styles": [],
"colors": [],
"filter_nodes": [
{
"type": 1,
"id": 4834126,
"children": [
{
"id": 4834127,
"type": 2,
"children": [
{
"agg_filter_id": 4834127,
"value": "1000002024"
}
]
},
{
"id": 4834128,
"type": 1
}
]
}
]
}
7. Request header configuration
headers = {
"content-type": "application/json;charset=UTF-8",
"x-channel-id": "8"
}
8. Create a folder for posters
""" Create a folder for posters """
def create_folder(path):
if not os.path.exists(path):
os.mkdir(path)
9. Get poster list
""" Get poster list """
def get_poster_list():
return requests.post(url, data=json.dumps(data1), headers=headers)
10. Save the poster
""" Save the poster """
def save_poster(url):
request = requests.get(url)
with open(f'./images/{int(round(time.time() * 1000))}-{random.randint(100,1000)}-poster.png', 'wb') as img:
img.write(request.content)
11. Download the posters
""" Download the posters """
def download_poster():
create_folder('./images')
res = get_poster_list()
for item in json.loads(res.text):
save_poster(item.get("preview").get("url"))
12. Complete code
import requests,json,time,random,os
url = 'https://www.gaoding.com/api/v3/cp/template-centers/v2/recommend-templates'
data = {
"page_num": 1,
"page_size": 500,
"styles": [],
"colors": [],
"filter_nodes": [
{
"type": 1,
"id": 4834126,
"children": [
{
"id": 4834127,
"type": 2,
"children": [
{
"agg_filter_id": 4834127,
"value": "1000002024"
}
]
},
{
"id": 4834128,
"type": 1
}
]
}
]
}
headers = {
"content-type": "application/json;charset=UTF-8",
"x-channel-id": "8"
}
""" Create a folder for posters """
def create_folder(path):
if not os.path.exists(path):
os.mkdir(path)
""" Get poster list """
def get_poster_list():
return requests.post(url, data=json.dumps(data), headers=headers)
""" Save the poster """
def save_poster(url):
request = requests.get(url)
with open(f'./images/{int(round(time.time() * 1000))}-{random.randint(100,1000)}-poster.png', 'wb') as img:
img.write(request.content)
""" Download the posters """
def download_poster():
create_folder('./images')
res = get_poster_list()
for item in json.loads(res.text):
save_poster(item.get("preview").get("url"))
if __name__ == "__main__":
download_poster()
13. Run Preview

WXRUI Experience QR code

download
My blog , Welcome to exchange !
my CSDN Blog , Welcome to exchange !
Wechat applet realizes some functions of Gaode map DEMO download
Wechat applet implementation MUI Partial effect of DEMO download
边栏推荐
- 历史上的今天:PHP公开发布;iPhone 4 问世;万维网之父诞生
- Sword finger offer II 061 And the minimum k-number pair large top heap method
- How to realize face verification quickly and accurately?
- 肆拾肆- 微信小程序 canvas 解锁及弹簧物理效应动画
- Tensorflow new document publishing: add CLP, dtensor The most advanced model is ready!
- AI candidates scored 48 points in challenging the composition of the college entrance examination; IBM announced its withdrawal from the Russian market and has suspended all business in Russia; Opencv
- 【PHP】代码复用特殊类Trait的简要说明和相关举例
- Implementing recurrent neural networks from scratch -- [torch learning notes]
- N-grams language model -- [torch learning notes]
- Some instructions in dict intersect with the difference sum in set, and increase or decrease elements
猜你喜欢

106. construct binary tree from middle order and post order traversal sequence

Thirty seven - JS tried fractal graphics on canvas (I) drew an ordinary box graph

Learning fuzzy from SQL injection to bypass the latest safe dog WAF
![[optics] double slit interference with GUI Based on MATLAB simulation light](/img/9a/0c33e71111b878e48ef3a1cc77ab3c.png)
[optics] double slit interference with GUI Based on MATLAB simulation light

15 must know MySQL index failure scenarios, stop stepping on the pit!

塔米狗知识|2022年新的国有产权非公开协议转让新规解读来了!

Lua call principle demonstration (Lua stack)

“当你不再是程序员,很多事会脱离掌控”—— 对话全球最大独立开源公司SUSE CTO...

【水果识别】基于形态学实现水果识别含Matlab源码

UnsupportedOperationException异常解决
随机推荐
106. construct binary tree from middle order and post order traversal sequence
Web版SSH客戶端Sshwifty
Is flush app transaction safe
4. 软件工程:航空行李托运费计算
Mysql数据库头歌实训任务存储过程如何通关?
How to pass the MySQL database header song training task stored procedure?
IBM announced its withdrawal from Russia after a loss of $300million!
历史上的今天:PHP公开发布;iPhone 4 问世;万维网之父诞生
dict中的部分指令与set中的差和交集与增减元素
中信建投是安全的吗
excel条件格式使用详细步骤
肆拾肆- 微信小程序 canvas 解锁及弹簧物理效应动画
Some instructions in dict intersect with the difference sum in set, and increase or decrease elements
PIC模拟(Particle-in-Cell Codes) (任务A和任务C)
[PHP] brief description and relevant examples of the special class trail for code reuse
三拾壹- NodeJS簡單代理池(合) 之 MongoDB 鏈接數爆炸了
leetcode. 36 --- effective Sudoku
go strconv包
Other permission verification methods
AI candidates scored 48 points in challenging the composition of the college entrance examination; IBM announced its withdrawal from the Russian market and has suspended all business in Russia; Opencv
