#!/usr/bin/python import re import urllib def getHtml(url): page = urllib.urlopen(url) html = page.read() return html def getImg(html): reg = r'src="(.*?\.jpg)" width' imgre = re.compile(reg) imglist = re.findall(imgre, html) num = 0 for imgurl in imglist: urllib.urlretrieve(imgurl, '%d.jpg' % num) num += 1 html = getHtml('http://tieba.baidu.com/p/1805615679') getImg(html)
原文地址:http://blog.csdn.net/aspnet_lyc/article/details/39999853