In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you how python crawls Arena of Valor's whole skin simple implementation code, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.
I believe that now many people like to play Arena of Valor this mobile game, the good-looking skin inside is adorable. So have you ever thought of setting Arena of Valor's high-definition skin as wallpaper, like this
How to use python code to download all high-definition skins of Arena of Valor.
The specific operation is divided into two steps:
1. Find the address of the skin picture
two。 Download pictures
1. Look for the address of the skin picture 1. Find the list of heroes
Baidu "Arena of Valor" entered the official website https://pvp.qq.com/. Here, take Goole Chrome browser as an example, select developer tools among more tools, or press F12 directly to enter the debugging interface, and then press F5 to refresh the interface.
The herolist.json file identified in the figure is the list of heroes we need, including hero number, hero name, hero type, skin name and other information. Right-click on the file to copy the link, http://pvp.qq.com/web201605/js/herolist.json
Next, verify that what we are looking for is correct, code 1:
Import urllib.requestimport jsonimport osresponse = urllib.request.urlopen ("http://pvp.qq.com/web201605/js/herolist.json")hero_json = json.loads (response.read ()) hero_num = len (hero_json) print (hero_json) print (" hero_num: ", str (hero_num))
The above code reads the list of heroes, stores them in hero_json, and gets the number of heroes. The results are as follows
two。 Find the hero skin address.
Click on the "Game Information" tab on the home page, enter the new page, and then click on a hero profile at random to enter the hero profile page. Take Li Bai as an example. The same F12 and then F5, sweep the mouse over several skins of Li Bai at one time.
Let's look at the debug window.
You can see that there are a total of 5 high-definition skins of Li Bai. Similarly, we right-click on one skin to copy the link to get:
Https://cache.yisu.com/upload/information/20201211/272/44775.jpg
This is the hero skin link we want.
By analyzing this link, we can find that '131' is the hero's number, and the last'- 5'is the hero's skin number. At this point, we have got all the information we need on the browser.
two。 Download picture 1. Heroes have several skins.
In the herolist.json file obtained in the first step, there is a 'skin_name' field. We only need to parse this field to get the number and name of the skin. The test code is followed by code 1, and code 2 is as follows:
Hero_name = hero_json [0] ['cname'] skin_names = hero_json [0] [' skin_name'] .split ('|') skin_num = len (skin_names) print ('hero_name:', hero_name) print ('skin_names:', skin_names) print ('skin_num:' + str (skin_num))
The running results after the test are as follows:
You can see that Lianpo has a total of two skins, the names of which are Justice detonation and Hell Rock Soul.
two。 Download a file
Use the urlretrieve interface to download the file, and consider two issues:
1. Check whether the folder exists. If it does not exist, create it.
Save_dir ='D:\ heroskin\\'if not os.path.exists (save_dir): os.mkdir (save_dir)
two。 Check to see if the picture file exists and skip downloading if it exists.
If not os.path.exists (save_file_name): urllib.request.urlretrieve (skin_url, save_file_name)
Code three is as follows:
Save_dir ='D:\ heroskin\\'if not os.path.exists (save_dir): os.mkdir (save_dir) for i in range (hero_num): # get the hero skin list skin_names = hero_ json [I] ['skin_name'] .split (' |') for cnt in range (len (skin_names)): save_file_name = save_dir + str (hero_ json [I] ['ename']) +' -'+ hero _ skin_ [I] ['cname'] +' -'+ skin_ namespace [cnt] + '.jpg' skin_url = 'http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/'+str(hero_json[i]['ename'])+' /'+ str (hero_ json [I] ['ename']) +'-bigskin-' + str (cnt+1) + '.jpg' print (skin_url) if not os.path.exists (save_file_name): urllib.request.urlretrieve (skin_url) Save_file_name)
Summary
Finally, the complete code is as follows, excluding comments and blank lines with a total of 16 lines of code, realizing the function of downloading all Arena of Valor's high-definition skin:
Import urllib.requestimport jsonimport osresponse = urllib.request.urlopen ("http://pvp.qq.com/web201605/js/herolist.json")hero_json = json.loads (response.read ()) hero_num = len (hero_json) save_dir ='D:\ heroskin\\'if not os.path.exists (save_dir): os.mkdir (save_dir) for i in range (hero_num): # get hero skin list skin_names = hero_ json [I ] ['skin_name'] .split (' |') for cnt in range (len (skin_names)): save_file_name = save_dir + str (hero_ json [I] ['ename']) +' -'+ hero_ json [I] ['cname'] +' -'+ skin_ namespace [CNT] + .jpg 'skin_url =' http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/'+str(hero_json[i][' Ename']) +'/'+ str (hero_ json [I] ['ename']) +'-bigskin-' + str (cnt+1) + '.jpg' print (skin_url) if not os.path.exists (save_file_name): urllib.request.urlretrieve (skin_url) Save_file_name)
Haha, it seems how important it is to master a language.
The above content is the simple implementation code of how python crawls the whole skin of Arena of Valor. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.