首页 > 编程语言 > 详细

Python学习笔记第25天

时间:2020-05-04 00:53:45      阅读:77      评论:0      收藏:0      [点我收藏+]

谏言:穷则独善其身,达则兼济天下

import requests
# 请求地址
def get_lol_list():
    url=https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js
    # 请求头
    headers={
        User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36 
    }
    # 发送请求
    img_lol=requests.get(url,headers=headers).json()
    hero_list=img_lol[hero]
    for lol in hero_list:
        id=lol[heroId]
        new_url=https://game.gtimg.cn/images/lol/act/img/js/hero/{}.js.format(id)
        img_data=requests.get(new_url,headers=headers).json()
        skins_list=img_data[skins]
        for j in skins_list:
            # print(j)
            name=j[name]
            mainimg=j[mainImg]
            # print(name,mainimg)
            if mainimg:
                res=requests.get(mainimg).content
#             try:
                with open(皮肤图片/+name+.jpg,wb) as f:
                    f.write(res)
                    print("正在下载"+name)
#             except 
                

get_lol_list()

技术分享图片

 

 技术分享图片

 

Python学习笔记第25天

原文:https://www.cnblogs.com/python-study-notebook/p/12824634.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!