免费的壁纸api
# 联想壁纸
from enum import Enum
import requests
class 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',
# 必须得用这个ua
'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 token
def 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 response
def 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 response
def classes(self):
"""
壁纸分类接口
:return:
"""
url = self.wallpaper_url + '/classes'
response = requests.get(url, headers=self.headers)
return response
def 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 response
def class_wallpaper_list(self, skip: int = 0, classId: int = -1, tagId: int = -1, priceId: int = 0):
"""
根据分类接口获取壁纸信息
:return:
"""
# params = {
# 'skip': str(skip), # 页码
# 'limit': str(54), # 每页?条
# 'count': str(76873),
# 'tagId': tagId,
# 'colorId': str(-1),
# 'classId': classId,
# 'refresh': 'true',
# 'priceId': priceId # 资费 -1 全部, 0 免费, 1 付费
# }
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