使用python下载bing图片(代码)

直接上代码:

代码如下:

# -*- coding: cp936 -*-import urllibimport osprint ‘download data……’url = ‘http://cn.bing.com’urlfile = urllib.urlopen(url)data = urlfile.read()urlfile.close()data = data.decode(‘utf-8’)pre = ‘g_img={url:\”index1 = data.find(pre) + len(pre)index2 = data.find(‘\”, index1)imgurl = data[index1 : index2]preimg = u’h3>今日图片故事index3 = data.find(preimg) + len(preimg)index4 = data.find(‘>’, index3) + 1index5 = data.find(‘