有接口下载不是难事。 很好已经执行 并且下载成功了
有些头像没有 sub_item['name'] 学习一下,感觉很不错哦, ltgb 发表于 2024-1-26 13:04
有没有打包的成品
打包好的成品如下:
链接:https://pan.baidu.com/s/1Kou9Xc9Vd3UdY1JRuLzuzQ
提取码:5yzk 米游社的皮肤合装备在哪? 很简单
import requests
import jsonpath
# requests禁用安全请求警告
requests.packages.urllib3.disable_warnings()
req_headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36'
}
url = "https://bbs-api-static.miyoushe.com/misc/wapi/avatar_set"
res = requests.get(url=url, headers=req_headers, verify=False)
# print(res.json())
for data_list in res.json()['data']['list']:
# print(data_list)
data_list_name = data_list['name']
for icon_data in data_list['list']:
print("下载", icon_data)
res = requests.get(url=icon_data['icon'], headers=req_headers)
with open(f"./img/{data_list_name}-{icon_data['id']}-{icon_data['name']}.png", "wb") as f:
f.write(res.content)
页:
[1]