圆月山庄资源网 Design By www.vgjia.com
直接上代码:
复制代码 代码如下:
<span style="font-family: arial,helvetica,sans-serif; font-size: 16px;"># -*- coding: cp936 -*-
import urllib
import os

print '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>今日图片故事</h3><a href='
index3 = data.find(preImg) + len(preImg)
index4 = data.find('>', index3) + 1
index5 = data.find('<', index4)

imgName = data[index4 : index5] +u'.jpg'

if os.path.exists(imgName) == False:
    print 'Download image......'
    urllib.urlretrieve(imgUrl, imgName)
print 'Download complete'
os.startfile(imgName)
</span>
标签:
Python下载,Bing图片

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com