In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "Python how to capture the full set of skin of Arena of Valor through the requests module", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "Python how to capture the full set of Arena of Valor skin through the requests module" this article.
Development tools
Python version: 3.6.4
Related modules:
Requests module
Urllib module
And some modules that come with Python.
Environment building
Install Python and add it to the environment variable, and pip installs the relevant modules you need.
Train of thought analysis
1. Open the official Arena of Valor wallpaper website
Website address: https://pvp.qq.com/web201605/wallpaper.shtml
2. Shortcut key F12, call up the console to grab the package
3. Find the correct link and analyze
4. View the format of returned data
5. Parse url links
6. Check whether the url content is the desired picture, and find that it is actually a thumbnail.
7. Analyze the website, click on a wallpaper and view the links in the specified format.
8. Find the destination address
9. Analyze the link difference between the target link and the thumbnail
Thumbnails: http://shp.qpic.cn/ishow/2735090714/1599460171_84828260_8311_sProdImgNo_6.jpg/200
Target picture: http://shp.qpic.cn/ishow/2735090714/1599460171_84828260_8311_sProdImgNo_6.jpg/0
As you can see, replacing 200 with 0 after the thumbnail address in the specified format is the real picture of the target.
The code implements import os, time, requests, json, refrom retrying import retryfrom urllib import parse class HonorOfKings:''This is a main Class, the file contains all documents. One document contains paragraphs that have several sentences It loads the original file and converts the original file to new content Then the new content will be saved by this class''def _ init__ (self, save_path='./heros'): self.save_path = save_path self.time = str (time.time ()) .split ('.') Self.url = 'https://apps.game.qq.com/cgi-bin/ams/module/ishow/V1.0/query/workList_inc.cgi?activityId=2735&sVerifyCode=ABCD&sDataType=JSON&iListNum=20&totalpage=0&page={}&iOrder=0&iSortNumClose=1&iAMSActivityId=51991&_everyRead=true&iTypeId=2&iFlowId=267733&iActId=2735&iModuleId=2735&_=%s'% self.time [0] def hello (self):' 'This is a welcome speech: return: self' '' print ("*" 50) print ('* 18 + 'Arena of Valor wallpapers download') print ('* 5 + 'author: Felix Date: 2020-05-20 1314) print ("*" * 50) return self def run (self):' 'The program entry'' Print ('↓' * 20 + 'format:' + '↓' * 20) print ('1. Thumbnail 2.1024x768 3.1280x720 4.1280x1024 5.1440x900 6.1920x1080 7.1920x1200 8.1920x1440') size = input ('Please enter the format serial number you want to download, default 6') size = size if size and int (size) in [1, 2, 3, 4, 5, 6, 7, 8] else 6 print ('--download begins.') Page = 0 offset = 0 total_response = self.request (self.url.format (page)). Text total_res = json.loads (total_response) total_page =-- int (total_res ['iTotalPages']) print ('-total {} pages. Format (total_page) while True: if offset > total_page: break url = self.url.format (offset) response = self.request (url). Text result = json.loads (response) now = 0 for item in result ["List"]: now + = 1 Hero_name = parse.unquote (item ['sProdName']). Split (' -') [0] hero_name = re.sub (r'[[]:. | @ # $% ^ & ()]' '', hero_name) print ('- downloading page {} heroic progress {} / {}...'. Format (offset, hero_name, now Len (result ["List"])) hero_url = parse.unquote (item ['sProdImgNo_ {}' .format (str (size))]) save_path = self.save_path +'/'+ hero_name save_name = save_path +'/'+ hero_url.split ('/') [- 2] if not os.path.exists (save _ path): os.makedirs (save_path) if not os.path.exists (save_name): with open (save_name) 'wb') as f: response_content = self.request (hero_url.replace ("/ 200", "/ 0"). Content f.write (response_content) offset + = 1 print ('-download completed.') @ retry (stop_max_attempt_number=3) def request (self Url):''Send a request: param url: the url of request: param timeout: the time of request: return: the result of request' 'response = requests.get (url, timeout=10) assert response.status_code = = 200 return response if _ _ name__ = = "_ main__": HonorOfKings (). Hello (). Run ()
The complete source code for this issue can be obtained by private information.
Result of code running
The above is all the contents of the article "how Python crawls Arena of Valor's full set of skin through requests module". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.