# -*- coding: utf-8 -*-
import urllib,time,os,Image,win32gui,win32con,win32api
class StealBing:
def __init__(self):
self.content = urllib.urlopen('http://cn.bing.com/').read()
self.bgImageUrl = ''
self.localFileName = ''
self.localBMPFileName = ''
def parserImageURL(self):
tempStr = self.content[self.content.index('g_img={url:')+12:]
self.bgImageUrl = tempStr[:tempStr.index('id:\'bgDiv\'')-2]
def createLocalFileName(self):
randomStr = time.strftime("%Y%m%d", time.localtime())
self.localFileName = 'D:/Bing/' + randomStr + '.jpg'
self.localBMPFileName = 'D:/Bing/' + randomStr + '.bmp'
def downloadImage(self):
if self.bgImageUrl == '':
self.parserImageURL()
if self.localFileName == '':
self.createLocalFileName()
urllib.urlretrieve(self.bgImageUrl, self.localFileName)
def updateBGImage(self):
img = Image.open(self.localFileName)
img.save(self.localBMPFileName)
os.remove(self.localFileName)
k = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\\Desktop",0,win32con.KEY_SET_VALUE)
win32api.RegSetValueEx(k, "WallpaperStyle", 0, win32con.REG_SZ, "2") #2拉伸适应桌面,0桌面居中
win32api.RegSetValueEx(k, "TileWallpaper", 0, win32con.REG_SZ, "0")
win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, self.localBMPFileName , 1+2)
if __name__ == '__main__':
stealBing = StealBing()
stealBing.downloadImage()
stealBing.updateBGImage()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有