#coding=utf-8

import re
import urllib

def getHtml(url): #获取url对应得源码 page = urllib.urlopen(url) html = page.read() return html def getImg(html): #获取 reg = r'src="(.+?\.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)

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

相关文章:

  • 2021-12-15
  • 2021-12-15
  • 2021-09-06
  • 2022-12-23
  • 2021-09-12
  • 2021-06-23
  • 2021-11-23
  • 2021-12-07
猜你喜欢
  • 2022-02-01
  • 2021-07-11
  • 2021-12-08
  • 2021-10-28
  • 2022-01-07
  • 2021-12-10
  • 2021-12-10
相关资源
相似解决方案