标签:style blog http os 2014 art
微软bing搜索每天都会换一张壁纸,而且分辨率都高,很适合当做壁纸,写了一个python去获取张壁纸,代码很简单
import urllib import re import time def getHtml(url): return urllib.urlopen(url).read() def getImgUrl(html): reg=re.compile(r‘(http://s.cn.bing.net/.*?\.jpg)‘) #正则式 url=reg.findall(html) print url[0] return url[0] def downloadImg(url,path): xpath=path+‘\\bing.jpg‘ print xpath urllib.urlretrieve(url,xpath) if __name__==‘__main__‘: start=time.time() html=getHtml(‘http://cn.bing.com/‘) url=getImgUrl(html) downloadImg(url,‘F:\\python‘) end=time.time() print ‘done %.2f seconds‘ % (end-start)
python获得bing壁纸,并下载到本地,码迷,mamicode.com
标签:style blog http os 2014 art
原文地址:http://blog.csdn.net/iloster/article/details/24597819