爬虫===爬取王者荣耀所有英雄皮肤图片

时间:2022-03-26 18:50:51
import requests
import os
import time


url = "http://pvp.qq.com/web201605/js/herolist.json"
img_url = "https://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/504/504-bigskin-1.jpg"


save_dir = 'D:\\heroskin\\'
if not os.path.exists(save_dir):
    os.mkdir(save_dir)


content = requests.get(url).json()

hero_num = len(content)


for i in range(hero_num):
    # 获取皮肤列表
    hero_skins = content[i]["skin_name"].split("|")
    hero_name = content[i]["cname"]
    hero_ename = content[i]["ename"]
for hero_skin in range(len(hero_skins)): save_name = save_dir + str(hero_name) + "-" + \ str(hero_skins[hero_skin])+".jpg" re_num = hero_skin+1 with open(save_name, 'wb') as file: file.write(requests.get(f"https://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/{hero_ename}/{hero_ename}-bigskin-{re_num}.jpg").content)