import re import urllib def getHtml(url): page=urllib.urlopen(url) html=page.read() return html def getpic(html): s=r'src="(.*?.jpg)" pic_ext' reg=re.compile(s) #这句可有可无 piclist=re.findall(reg,html) x=0 for imgurl in piclist: urllib.urlretrieve(imgurl,'%d.jpg'%x) x=x+1 html=getHtml('http://tieba.baidu.com/p/3216903619') getpic(html)