吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]
查看: 5047|回复: 58
收起左侧

[Python 转载] 英雄联盟全英雄皮肤下载

  [复制链接]
13955925361 发表于 2025-3-26 22:08
文件自动创建在ide本地目录,代码直接复制粘贴就行,我用的是pycharm, 下载包括大屏和小屏图片,如不需要注释掉其中一行就行,还有一行是英雄声音文件,如有需要自己写个,mp3保存

[Python] 纯文本查看 复制代码
from threading import Thread
import requests,os


class Spider(object):
    os_path = os.getcwd() + '/英雄联盟图片/'
    if not os.path.exists(os_path):
        os.mkdir(os_path)

    def __init__(self):
        self.hero_list_url = 'https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'
        self.headers = {
            'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0"
            }
        self.hero_url = 'https://game.gtimg.cn/images/lol/act/img/js/hero/{}.js'

    def parse_hero_list_url(self):
        response = requests.get(self.hero_list_url, headers=self.headers).json()
        hero_list = response['hero']
        for hero in hero_list:
            heroId = hero['heroId']
            title = hero['name']
            name = hero['title']
            ## selectAudio是英雄声音文件,如需下载自己写个保存音乐的代码,示例: with open(self.os_path + song_name + '.mp3', 'wb') as f: f.write(data)
            selectAudio = hero['selectAudio']
            os_hero_path = self.os_path + f"/{name}/"
            if not os.path.exists(os_hero_path):
                os.mkdir(os_hero_path)
            hero_url = self.hero_url.format(heroId)
            # Thread(target=self.parse_hero_url, args=(hero_url, os_hero_path,name)).start()
            self.parse_hero_url(hero_url, os_hero_path, name)

    def parse_hero_url(self, hero_url, os_hero_path, name):
        response = requests.get(hero_url, headers=self.headers).json()

        skins_list = response['skins']
        for skin in skins_list:
            centerImg = skin["centerImg"]
            loadingImg = skin['loadingImg']
            skinname = skin['name']
            ##这一行if是下载电脑端图片的代码,可以注释掉下面手机端
            if centerImg:
                Thread(target=self.parse_save_skin, args=(os_hero_path, centerImg, name, skinname, "电脑版")).start()
            #这一行if是下载手机版的代码,根据自己需要注释相应代码
            if loadingImg:
                Thread(target=self.parse_save_skin, args=(os_hero_path, loadingImg, name, skinname, "手机版")).start()

    def parse_save_skin(self, os_hero_path, img_url, name, skinname, type_img):
        skinname = skinname.replace("-", "_").replace("/", "_").replace("\\", "_")
        data = requests.get(img_url, headers=self.headers).content
        with open(f"{os_hero_path}{skinname} -- {type_img}.jpg", 'wb') as f:
            f.write(data)
            print(f"英雄 {name}的皮肤 -- {skinname} -- 下载完成")


if __name__=='__main__':
    s=Spider()
    s.parse_hero_list_url()

免费评分

参与人数 10吾爱币 +5 热心值 +10 收起 理由
EdgeHis + 1 + 1 热心回复!
shengruqing + 1 热心回复!
Ayue1234 + 1 + 1 我很赞同!
Vladimirx + 1 我很赞同!
Wodajunge666 + 1 + 1 我很赞同!
SOMETHINGWRONG + 1 我很赞同!
laozhang4201 + 1 + 1 热心回复!
CGQC + 1 我很赞同!
wuai5211314 + 1 感谢分享!
chinawolf2000 + 1 + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

吾爱不解 发表于 2025-3-27 07:17
所有人第一眼看成了 《英雄联盟全英雄皮肤游戏下载》
 楼主| 13955925361 发表于 2025-3-27 01:26
本帖最后由 13955925361 于 2025-3-27 01:30 编辑

各位,不是呀,我这是快速下载皮肤图片到本地,可以当壁纸用,玩游戏的时候皮肤是不会做替换的。
头像被屏蔽
q7420 发表于 2025-3-26 23:56
樱花奈落 发表于 2025-3-27 00:12
不如测试服,多到不知道怎么选
wuai5211314 发表于 2025-3-27 00:30
会封号不?
leqaq 发表于 2025-3-27 01:15

不会吧,客户端都没启动呢,只是从本地搞文件
BayMax2911 发表于 2025-3-27 02:18
13955925361 发表于 2025-3-27 01:26
各位,不是呀,我这是快速下载皮肤图片到本地,可以当壁纸用,玩游戏的时候皮肤是不会做 ...

哈哈哈。。。。orz
elicdr 发表于 2025-3-27 07:08
还是测试服吧,这玩意有封号风险
头像被屏蔽
1230tjh 发表于 2025-3-27 08:03
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-7-21 21:20

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表