python king of glory wallpaper

The effect is as follows#

code show as below#

#! /usr/bin/env python
# encoding: utf-8import os, time, requests, json, re
from retrying import retry
from urllib import parse

classHonorOfKings:

 def __init__(self, save_path='/Users/cuixiaoyan/Downloads'):
  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+'King of glory wallpaper download')print(' '*5+'Author:cxy')print("*"*50)return self

 def run(self):'''
  The program entry
        '''
  print('↓'*20+'Format selection: '+'↓'*20)print('1.Thumbnail 2.1024x768 3.1280x720 4.1280x1024 5.1440x900 6.1920x1080 7.1920x1200 8.1920x1440')
  size =input('Please enter the serial number of the format you want to download, the default is 6:')
  size = size if size and int(size)in[1,2,3,4,5,6,7,8]else6print('---Download starts...')
  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('---In total{}page...'.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 =0for item in result["List"]:
    now +=1
    hero_name = parse.unquote(item['sProdName']).split('-')[0]
    hero_name = re.sub(r'[【】:.<>|·@#$%^&() ]','', hero_name)print('---Downloading{}page{}Hero 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):withopen(save_name,'wb')as f:
      response_content = self.request(hero_url.replace("/200","/0")).content
      f.write(response_content)
   offset +=1print('---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 ==200return response

if __name__ =="__main__":HonorOfKings().hello().run()

Recommended Posts

python king of glory wallpaper
Python crawls a full set of skins for the glory of the king
7 features of Python3.9
Basics of Python syntax
Basic syntax of Python
Basic knowledge of Python (1)
Prettytable module of python
09. Common modules of Python3
Python crawls the full set of skins of the king pesticide
Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
In-depth understanding of python list (LIST)
Subscripts of tuples in Python
Consolidate the foundation of Python(6)
Analysis of JS of Python crawler
Consolidate the foundation of Python(5)
Python implementation of gomoku program
Analysis of Python Sandbox Escape
Some new features of Python 3.10
Deep understanding of Python multithreading
Analysis of Python object-oriented programming
Python version of OpenCV installation
9 feature engineering techniques of Python
matplotlib of python drawing module
Python method of parameter passing
Consolidate the foundation of Python (3)
Collection of Python Common Modules
The usage of wheel in python
Summary of logarithm method in Python
Use of Pandas in Python development
Detailed implementation of Python plug-in mechanism
Detailed explanation of python sequence types
Implementation of reverse traversal of python list
Python implementation of IOU calculation case
Magic methods and uses of Python
In-depth understanding of Python variable scope
Python preliminary implementation of word2vec operation
Python handles the 4 wheels of Chinese
Python calculation of information entropy example
Implementation of python selenium operation cookie
Use of numpy in Python development
Python simulation of the landlord deal
What is the use of Python
Scrapy simulation login of Python crawler
Analysis of Python conditional control statements
Black hat programming application of Python1
Detailed usage of dictionary in Python
Usage of os package in python
Several common modes of Python functions
A summary of 200 Python standard libraries!
Mongodb and python interaction of python crawler
Implementation of python3 registration global hotkey
Implementation of python student management system
There are several versions of python
Simple usage of python definition class
Summary of Python calling private attributes
Some examples of python operation redis
​Full analysis of Python module knowledge
Example operation of python access Alipay
The premise of Python string pooling
Secrets of the new features of Python 3.8