python3 简单抓取图片2

原文链接: http://www.cnblogs.com/vsmart/p/7769032.html
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

转载于:https://www.cnblogs.com/vsmart/p/7769032.html

猜你喜欢

转载自blog.csdn.net/weixin_30559481/article/details/94800210