from enum import Enumimport requestsclass LenovoTopHeadersTypePage ( Enum) : """头部页面类型wallpaper 精选wallpaperHot 热门wallpaperRank 排行""" wallpaper = 'wallpaper' wallpaperHot = 'wallpaperHot' wallpaperRank = 'wallpaperRank' class LenovoWallpaper : base_url = 'https://pc-store.lenovomm.cn' wallpaper_url = base_url + '/wallpapercontent/wallpaper' def __init__ ( self) : self. headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36&PCStore' , 'token' : 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcyI6IndpbjEwIiwiY2giOiI5LjAuMTMwMC4wMjAxIiwibXQiOiIxMC4wLjIyNjIxIiwib3NCaXQiOiI2NCIsInNuIjoiMjQ1Nzc5MTFiYjE0NzYzYzBlOWRmMjFkMzUyMzc5OTAzNzM3NjQyNDkxZWYyOThmYzI1NjRkZWY4NWM5MDc5MiIsImV4cCI6MTcxMzAwNDcwMiwidXVpZCI6IjdEN0E3RTVDLTVBQ0UtMTFFRS04REM3LUQ0N0UwMDM3M0YwMCIsIm1hYyI6Ijc0MTNlYTdlOGRiYyJ9.BjW0q5rGDps5aGyWPpU4hyUPS2_iJumajXrx7VrpP6E' } def get_token ( self) : data = { "channelInfo" : { "businessChannel" : "Nil" } , "commonData" : { "channel" : "20005" , "from" : "indstore" , "mac" : "7413ea7e8dbc" , "mt" : "10.0.22621" , "os" : "6.1.50.12061" , "osBit" : "64" , "pcmStoreVer" : "9.0.1200.1220" , "pcmVer" : "6.1.50.12061" , "preVersion" : "" , "sn" : "123108Z0M768120852C" , "uuid" : "7D7A7E5C-5ACE-11EE-8DC7-D47E00373F00" , "ver" : "9.0.1330.201" , "versionCode" : "9.0.1330.201" , "versionName" : "9.0.1330.201" } , "settingInfo" : { "smbOptions" : "1" } } url = self. base_url + '/sysconfigservice/indep/business_parameter' response = requests. post( url, headers= self. headers, json= data) token = response. json( ) . get( 'data' , { } ) . get( 'btoken' , None ) return tokendef banner ( self, page_type: LenovoTopHeadersTypePage = LenovoTopHeadersTypePage. wallpaper) : """精选、热门、排行顶部横幅内容:param page_type::return:""" url = self. wallpaper_url + '/banner/top_banner_content_v2' params = { 'pageType' : page_type. value} response = requests. get( url, params= params, headers= self. headers) return responsedef rank_more ( self, rank_id: int = 2707 ) : """排行:param rank_id::return""" url = self. wallpaper_url + '/rank_more' params = { 'code' : rank_id, 'limit' : 48 , 'skip' : 48 , 'wallpaperId' : '' } response = requests. get( url, params= params, headers= self. headers) return responsedef classes ( self) : """壁纸分类接口:return:""" url = self. wallpaper_url + '/classes' response = requests. get( url, headers= self. headers) return responsedef group_content ( self, page_type: LenovoTopHeadersTypePage = LenovoTopHeadersTypePage. wallpaper) : """页面内容:param page_type::return:""" url = self. wallpaper_url + '/group_content' params = { 'pageType' : page_type. value} response = requests. get( url, params= params, headers= self. headers) return responsedef class_wallpaper_list ( self, skip: int = 0 , classId: int = - 1 , tagId: int = - 1 , priceId: int = 0 ) : """根据分类接口获取壁纸信息:return:""" url = "https://pc-store.lenovomm.cn/wallpapercontent/wallpaper/class_wallpaper_list" params = { "skip" : f" { skip} " , "limit" : "54" , "count" : "76873" , "tagId" : f" { tagId} " , "colorId" : "-1" , "classId" : f" { classId} " , "refresh" : "true" , "priceId" : f" { priceId} " } response = requests. get( url, headers= self. headers, params= params) return response