import re
import urllib.request
def gethtml(url):
page=urllib.request.urlopen(url)
html=page.read()
return html
def getimg(html):
reg = r'src="(.+?\.jpg)" width'
img=re.compile(reg)
html=html.decode('utf-8')#python3
imglist=img.findall(gethtml("http://tieba.baidu.com/p/1753935195"))
x = 0
for imgurl in imglist:
urllib.request.urlretrieve(imgurl,'%s.jpg'%x)
x = x+1