爬取王者荣耀全皮肤
import requests
import json
import os
import time
start = time.time()
url = requests.get('http://pvp.qq.com/web201605/js/herolist.json').content
jsonFile = json.loads(url)
x = 0
hero_dir = 'D:\\code\\skin\\'
if not os.path.exists(hero_dir):
os.mkdir(hero_dir)
for m in range(len(jsonFile)):
ename = jsonFile[m]['ename']
cname = jsonFile[m]['cname']
skinName = jsonFile[m]['skin_name'].split('|')
skinNumber = len(skinName)
for bigskin in range(1, skinNumber+1):
urlPicture = 'http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/' + \
str(ename)+'/'+str(ename)+'-bigskin-'+str(bigskin)+'.jpg'
picture = requests.get(urlPicture).content
with open(hero_dir+cname+"-"+skinName[bigskin-1]+'.jpg', 'wb') as f:
f.write(picture)
x = x+1
print("正在下载....第"+str(x)+"张")
end = time.time()
time_second = end-start
print("共下载"+str(x)+"张,共耗时"+str(time_second)+"秒")
爬取王者荣耀全头像
import requests
import json
import os
import time
start = time.time()
url = requests.get('http://pvp.qq.com/web201605/js/herolist.json').content
jsonFile = json.loads(url)
x = 0
hero_dir = 'D:\\code\\avter\\'
if not os.path.exists(hero_dir):
os.mkdir(hero_dir)
for m in range(len(jsonFile)):
ename = jsonFile[m]['ename']
cname = jsonFile[m]['cname']
for bigskin in range(1):
urlPicture = 'http://game.gtimg.cn/images/yxzj/img201606/heroimg/' + \
str(ename)+'/'+str(ename)+'.jpg'
picture = requests.get(urlPicture).content
with open(hero_dir+cname+'.png', 'wb') as f:
f.write(picture)
x = x+1
print("正在下载....第"+str(x)+"张")
end = time.time()
time_second = end-start
print("共下载"+str(x)+"张,共耗时"+str(time_second)+"秒")