import requests
import json
resJson = requests.get("https://cn.bing.com/hp/api/model", timeout=1)
imgJson = json.loads(resJson.text)
imgUrl = ''
#获取标题
title = imgJson['MediaContents'][0]['ImageContent']['Title']
print(title)
"""
#webp格式
imgUrl = imgJson['MediaContents'][0]['ImageContent']['Image']['Url']
"""
#获取图片地址 jpg格式
imgUrl = 'https://cn.bing.com/' + imgJson['MediaContents'][0]['ImageContent']['Image']['Wallpaper']
print(imgUrl)
#保存到本地文件
resImg = requests.get(imgUrl, timeout=1)
with open("./" + title + ".jpg", "wb+") as f:
f.write(resImg.content)
print('success!!!')
必应bing每日壁纸python3获取
最新推荐文章于 2024-04-23 10:11:18 发布