import requests
import re
url = 'https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'
response = requests.get(url)
json_data = response.json()
skins=[]
for item in json_data['hero']:
skinsUrl = F'https://game.gtimg.cn/images/lol/act/img/js/hero/{item["heroId"]}.js'
skinsRes = requests.get(skinsUrl)
data = skinsRes.json()
skins.append(data['skins'])
for skin in skins:
for i in skin:
name = re.sub(r'/',' ',i['name'])
addres = f'e:/dama/python/pythonProject/LOLimg/{name}.jpg'
if i['mainImg']:
with open(addres, "wb") as fp:
try:
req = requests.get(i['mainImg'])
fp.write(req.content)
print(F"图片下载成功,图片地址:{i['mainImg']},图片名字:{i['name']}")
except:
print('图片下载失败')
