首页 > 编程语言 > 详细

python下爬某个网页的图片

时间:2014-04-26 06:41:32      阅读:418      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
#coding=utf-8

import re
import urllib

def getHtml(url): #获取url对应得源码 page = urllib.urlopen(url) html = page.read() return html def getImg(html): #获取 reg = rsrc="(.+?\.jpg)" pic_ext imgre = re.compile(reg) imglist = re.findall(imgre,html) x = 0 for imgurl in imglist: urllib.urlretrieve(imgurl,%s.jpg % x) #下载文件到本地,并且重命名 x+=1 html = getHtml("http://tieba.baidu.com/p/2460150866") #将这个页面的图片都爬下来 #print getImg(html)
bubuko.com,布布扣

 参考:http://www.cnblogs.com/fnng/p/3576154.html

python下爬某个网页的图片,布布扣,bubuko.com

python下爬某个网页的图片

原文:http://www.cnblogs.com/huhuuu/p/3689433.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!