python 获取网页图片 保存在本地

2015-09-10 0 539
python 获取网页图片 保存在本地
import urllib
import string
import re
def getHtml(url):
    page=urllib.urlopen(url)
    html=page.read()
    return html
def getPic(html):
    imgre=re.compile(r'src=".+?\.jpg" data-big-img')
    imglist=re.findall(imgre,html)
    print imglist
    x=0
    for imgurl in imglist:
        #src="http://www.xcxx.com/lld.jpg"'
        imgurl=imgurl.replace('src="','')
        imgurl=imgurl.replace('" data-big-img','')
        urllib.urlretrieve(imgurl,'%s.jpg' %x)
        x+=1
html=getHtml("http://www.xcxx.com/")

遇见资源网 python python 获取网页图片 保存在本地 http://www.ox520.com/15763.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务