爬虫===爬取王者荣耀所有英雄皮肤图片
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)
顺便提一下
如果有任何问题,你可以在这里找到我 ,软件测试交流qq群,209092584
纸上得来终觉浅,绝知此事要躬行!