Last active
December 23, 2022 11:48
-
-
Save manesec/5f9b67cbc50c24b075eabe273bcada75 to your computer and use it in GitHub Desktop.
Change wall paper on windows from bing wallpaper api.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [bingDailyWallpaper.py] by @manesec. | |
# Windows use only !! | |
# Run this program will change wallpaper on windows. | |
# This program using bing api to fetch bing Daily Wallpaper. | |
# Auto change wallpaper need to setup taskscheduler. | |
# taskscheduler: open "Run" (win + R) and type "taskschd.msc". | |
# pip3 install requests | |
import json, requests | |
import ctypes | |
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'} | |
print("[*] Getting wallpaper ...") | |
daily_json = requests.get("https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=EN-US").text | |
daily_json = json.loads(daily_json) | |
base_url = "https://cn.bing.com" + (daily_json["images"][0]["urlbase"]) + "_UHD.jpg" | |
tmp_path = "C:\\Windows\\Temp\\bing_wallpaper.png" | |
print("[*] Downloading wallpaper ...") | |
f = open(tmp_path,'wb+') | |
f.write(requests.get(base_url,headers=headers).content) | |
f.close() | |
print("[*] Changing wallpaper ...") | |
ctypes.windll.user32.SystemParametersInfoW(20, 0, tmp_path, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment