欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Python爬取王者荣耀英雄皮肤

程序员文章站 2022-05-08 13:07:59
...

Python爬取王者荣耀英雄皮肤:

from urllib import request
import   json
import urllib
url="https://pvp.qq.com/web201605/js/herolist.json"
# 请求一个数据
resp=request.urlopen(url)

result=resp.read().decode('utf-8')
result=json.loads(result)
print(result)
for item in result:
    heroName=item["cname"]
    heroNum=item["ename"]
    try:
        skin_name=item["skin_name"]
        skins=skin_name.split('|')
        pass
    except:
        shins=[]
        continue
    index=1
    baseUrl="https:"+"//game.gtimg.cn/images/yxzj/img201606/skin/hero-info/"
    for skin in skins:
        skinUrl=baseUrl+str(heroNum)+'/'+str(heroNum)+'-bigskin-'+str(index)+'.jpg'
        index+=1
        localfile = "D:/桌面/王者荣耀/" + heroName+skin+".jpg"
        urllib.request.urlretrieve(skinUrl,localfile)
        pass
    pass
    # print(heroNum)
    print(heroName,skin_name)

相关标签: Python python