Skip to content

Instantly share code, notes, and snippets.

@al1b al1b/
Created Jul 14, 2016

What would you like to do?
A Python script to download today picture of and set it as Windows Desktop wallpaper.
import re, os, tempfile
import urllib.request
from urllib.parse import urlparse
def getBing():
url = ''
response = urllib.request.urlopen(url)
data =
return data.decode('utf-8')
def downloadFile(url, file_name):
urllib.request.urlretrieve(url, file_name)
if __name__ == "__main__":
url ='g_img=\{url: \"(.*?)\"', getBing()).group(1).replace('\/', '/')
url = '' + url
fileName = tempfile.gettempdir() + '\\' + url.rsplit('/', 1)[-1]
downloadFile(url, fileName)
os.system('reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d {} /f'.format(fileName));
os.system('reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v WallpaperStyle /t REG_SZ /d 10 /f');
os.system('RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True')

This comment has been minimized.

Copy link

hadi-jabbari commented Jul 15, 2016


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.