liuyuqi-dellpc 2 years ago
parent
commit
8dc9cc401f
1 changed files with 0 additions and 72 deletions
  1. 0 72
      2.py

+ 0 - 72
2.py

@@ -1,72 +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    :   
-
-# 2. 编写一个工具(LOL皮肤下载工具) ----封装的思想
-#   给用户展示所有的英雄名称和id (在控制台输出 所有英雄的名称和id  每三个为一行)
-#   用户输入想要的英雄皮肤   (用户输入所需要的英雄id)
-#   如果有,则进行下载,      判断id是否在英雄id列表中存在
-#   如果没有让用户从新输入    y 继续数据皮肤信息    n 输出程序结束
-'''
-
-
-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)
-        yn = input("y 继续    n 输出程序结束:")
-        if yn == "n":
-            exit()
-
-
-def getHero():
-    getHeroId()
-    getHeroPic()
-
-
-if __name__ == '__main__':
-    getHero()