python3 简单抓取图片2

import urllib.request
import re

response = urllib.request.urlopen("http://tieba.baidu.com/p/2460150866")
page = response.read()
page = page.decode('utf-8')

imageList = re.findall(r'src="(.*?\.(jpg|png))" pic_ext',page)

j = 1
for i in imageList:
imgUrl = i[0]
urllib.request.urlretrieve(imgUrl,'./images/%d.jpg'%j)
j += 1
posted on 2017-11-01 23:04  vsmart  阅读(240)  评论(0编辑  收藏  举报