In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use Python to climb all the skin of League of Legends (lol). Many people may not understand it very well. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Mistress: "what's the matter, waiter? you look listless!"
Waiter: "Oh! don't mention it. I recently came into contact with a game called League of Legends. A lot of skin in the game needs to be bought, but I don't have enough money."
Mistress: "Why, if you save enough money, you still want to buy it?" do you want to eat or not?! if you ask me, you might as well climb down and enjoy the colorful skin of the hero, and you can save money for the meal. "
Waiter: "you're right, after all, eating is more important, so I'd better climb my skin and enjoy it."
First of all, we open the home page of League of Legends's official website at https://lol.qq.com/main.shtml, and then drop down to see a list of heroes, as shown in the figure:
Then randomly select a hero and click to take a look, as shown in the figure:
Click the right mouse button, and then select check to take a look at the URL of the skin, as shown in the figure:
Through observation, it can be found that the composition of hero skin URL is: https://game.gtimg.cn/images/lol/act/img/skin/big + hero id + skin id.jpg.
Let's first look at the skin id, that is, look at the number of skins, select the Network item of the developer tool, and then refresh the page. We can find that there is a request for 17.js. 17 is actually the hero id, as shown in the figure:
Then select the Response item to view the corresponding data, as shown in the figure:
We can see that the data is displayed on one line, which is not convenient to see. Let's format it, as shown in the figure:
Through observation, it can be found that the URL for obtaining the specified hero skin id is: https://game.gtimg.cn/images/lol/act/img/js/hero/ + hero id.js. The code for obtaining the skin id and downloading the skin image is as follows:
Hero_skin_url = 'https://game.gtimg.cn/images/lol/act/img/js/hero/' + hero_id +' .js'
# get the number of heroes' skins through url
Skin_text = requests.get (hero_skin_url) .text
Skin_json = json.loads (skin_text)
Skin_list = skin_json ['skins']
# get the skin name
Hero_skins.clear ()
For skin in skin_list:
Hero_skins.append (skin ['name']. Replace (' /','). Replace ('\,'). Replace (',')
# number of skin
Skins_num = len (hero_skins)
S =''
For i in tqdm (range (skins_num), desc=' ['+ hero_name +'] skin download'):
If len (str (I)) = = 1:
S = '00' + str (I)
Elif len (str (I)) = = 2:
S ='0' + str (I)
Elif len (str (I)) = = 3:
Pass
Try:
# stitching the url of the specified skin
Skin_url = 'https://game.gtimg.cn/images/lol/act/img/skin/big' + hero_id +''+ s + '.jpg'
Img = requests.get (skin_url)
Except:
# skip url without dazzling skin
Continue
# Save skin pictures
If img.status_code = = 200:
With open (hero_ Skins[ I] + '.jpg', 'wb') as f:
F.write (img.content)
Now all we need to get the hero id parameter is how to get all the hero id, return to the https://lol.qq.com/main.shtml page, open the developer tool and select Network, and then refresh the page. We can observe a request for hero_list.js, as shown in the figure:
Similar to the acquisition of skin id, all hero id can be obtained through this request. The code implementation is as follows:
Url = 'https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'
Hero_text = requests.get (url) .text
# convert to json format
Hero_json = json.loads (hero_text) ['hero']
Path = os.getcwd ()
# get the current folder path
Workspace = os.getcwd ()
# skin path
Skin_path = "{}\" .format (workspace, 'skins')
# iterate through the list
For hero in hero_json:
# put each hero's id and name in a dictionary
Hero_dict = {'id': hero [' heroId'], 'name': hero [' name']}
# put it on the list
Heros.append (hero_dict)
We can see: in the code, in addition to the hero id, the hero name is also obtained, and the id and name of each hero are put in a dictionary, and the corresponding dictionaries of all heroes are put in the list.
Finally, let's take a look at the download effect:
After reading the above, do you have any further understanding of how to climb all the skin of League of Legends (lol) with Python? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.