|
@@ -1,73 +0,0 @@
|
|
|
-import requests
|
|
|
-import os
|
|
|
-
|
|
|
-'''
|
|
|
-@Contact : liuyuqi.gov@msn.cn
|
|
|
-@Time : 2022/03/08 21:12:55
|
|
|
-@License : Copyright © 2017-2020 liuyuqi. All Rights Reserved.
|
|
|
-@Desc :
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-'''
|
|
|
-
|
|
|
-
|
|
|
-hero_list_url = "https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js"
|
|
|
-s = requests.Session()
|
|
|
-hero_id_list = []
|
|
|
-
|
|
|
-
|
|
|
-def getHeroId():
|
|
|
- global hero_id_list
|
|
|
- response = s.get(hero_list_url).json()
|
|
|
- hero_list = response["hero"]
|
|
|
- print("-----------所有英雄id和名字--------------------")
|
|
|
- input("按任意键继续")
|
|
|
- index = 1
|
|
|
- tmp = ""
|
|
|
- for hero in hero_list:
|
|
|
- tmp = tmp + hero["heroId"] + " " + hero["name"] + " "
|
|
|
- if index % 3 == 0:
|
|
|
- print(tmp)
|
|
|
- tmp = ""
|
|
|
- hero_id_list.append(hero["heroId"])
|
|
|
- index = index + 1
|
|
|
-
|
|
|
-
|
|
|
-def getHeroPic():
|
|
|
- while(1):
|
|
|
- mHeroId = input("用户输入所需要的英雄id:")
|
|
|
-
|
|
|
- for hero_id in hero_id_list:
|
|
|
- if mHeroId == hero_id:
|
|
|
- hero_img_url = "https://game.gtimg.cn/images/lol/act/img/js/hero/%s.js" % (
|
|
|
- hero_id)
|
|
|
- skin_list = s.get(hero_img_url).json()["skins"]
|
|
|
- for skin in skin_list:
|
|
|
- mainImg = skin["mainImg"]
|
|
|
- heroName = skin["heroName"]
|
|
|
- name = skin["name"]
|
|
|
- if not os.path.exists(heroName):
|
|
|
- os.mkdir(heroName)
|
|
|
- if mainImg == "":
|
|
|
- with open(heroName + "/" + name + ".jpg", "wb") as file:
|
|
|
- file.write(s.get(skin["chromaImg"]).content)
|
|
|
- else:
|
|
|
- with open(heroName + "/" + name + ".jpg", "wb") as file:
|
|
|
- file.write(s.get(skin["mainImg"]).content)
|
|
|
- print("下载结束,头像保存至当前目录\r\n\r\n")
|
|
|
- yn = input("y 继续 n 输出程序结束:")
|
|
|
- if yn == "n":
|
|
|
- exit()
|
|
|
-
|
|
|
-
|
|
|
-def getHero():
|
|
|
- getHeroId()
|
|
|
- getHeroPic()
|
|
|
-
|
|
|
-
|
|
|
-if __name__ == '__main__':
|
|
|
- getHero()
|