【爬虫】王者荣耀爬取英雄高清4K图片
作者:互联网
import requests
import json
resp = requests.get('https://pvp.qq.com/web201605/js/herolist.json')
heros_list = json.loads(resp.text)
print(heros_list)
for hero in heros_list:
id = hero['ename'] # 得到英雄的ID
name = hero['cname'] #得到英雄名字
skin_url = 'https://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/'+str(id)+'/'+str(id)+'-bigskin-1.jpg'
pic = requests.get(skin_url).content # 爬下来的是字节数据(Byte)
with open('E:/PyWorkSpace/Spider/skin_images/'+name+'.jpg',"wb") as laoxiao:
laoxiao.write(pic)
print("当前英雄"+name+" 皮肤图片爬取成功!")
效果图:
标签:hero,name,爬虫,爬取,json,4K,heros,skin,id 来源: https://blog.csdn.net/qq_41823684/article/details/114241695