python下载王者荣耀官网的全部高清壁纸

官网壁纸链接

python代码:

import os
import requests
import json
import re
from urllib import parse
path='E:\\me\\wallpaper\\wzry2'
size_list=['','','1024x768','1280x720','1280x1024','1440x900','1920x1080','1920x1280','1920x1440']
for page in range(0,1):
    print("第"+str(page)+"页")
    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=' + str(page)+'&iOrder=0&iSortNumClose=1&jsoncallback=jQuery17100316096202658831_1609834178230&iAMSActivityId=51991&_everyRead=true&iTypeId=2&iFlowId=267733&iActId=2735&iModuleId=2735&_=1609836282840'
    #
    im = requests.get(url)  # 请求url
    text = re.sub(r'^jQuery.*\(', '', im.text).replace('\n', '').replace('\r', '')
    siz = len(text)

    objStr = text[0:siz - 1] # 去掉最后的 )
    map = json.loads(objStr)
    lst = map["List"]
    print("本页个数"+str(len(lst)))
    for it in lst :
        name = parse.unquote(it["sProdName"]).replace(':','').replace('·','')
        print("正在执行"+name)
        for num in range(2, 9):
            url = parse.unquote(it["sProdImgNo_" + str(num)])
            url = url.replace('/200', '/0')
            dirPath = path + '\\' + str(size_list[num])
            if not os.path.exists(dirPath):
                os.mkdir(dirPath)
            os.chdir(dirPath)
            im = requests.get(url)  # 请求url
            if im.status_code == 200:
                open(name + '_' + size_list[num] + '.jpg', 'wb').write(im.content)  # 写入文件
posted @ 2021-01-06 21:01  孙行者、  阅读(430)  评论(0编辑  收藏  举报