🐟️ bing.py 💓 源码:
import requests
import time
import re
timestamp = str(int(time.time() * 1000))
url = 'https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&nc=' + timestamp + '&pid=hp'
headers = {
'User-Agent': ' '.join(['Mozilla/5.0 (Windows NT 10.0; Win64; x64; ServiceUI 14)',
'AppleWebKit/537.36 (KHTML, like Gecko)', 'Chrome/70.0.3538.102', 'Safari/537.36',
'Edge/18.18363'])
}
r = requests.get(url=url, headers=headers)
result = r.json()
image_url = result['images'][0]['url']
name = re.search( r'id=(.*\.jpg)&rf', image_url)
image_url = 'https://cn.bing.com' + image_url
print(image_url)
save_image_file = name[1]
r = requests.get(url=image_url, headers=headers)
with open(save_image_file, 'wb') as f:
f.write(r.content)
复制源码,保存文件 bing.py
双击使用,就能下载微软 bing 的壁纸