#!/usr/local/python3/bin/python3
#coding:UTF-8
import urllib
import urllib.request#python3 later ...
import re
def getHtml(url):
page = urllib.request.urlopen(url)#python later ...
html = page.read()
return html
def getImg(html):
reg = r'src="(.+?\.jpg)" pic_ext'
imgre = re.compile(reg)
html=html.decode('utf-8')#python3 later...
imglist = re.findall(imgre,html)
x = 0
for imgurl in imglist:
urllib.request.urlretrieve(imgurl,'%s.jpg' % x)#python3 later ...
x+=1
html = getHtml("http://tieba.baidu.com/p/2460150866")
print(getImg(html))
python3 爬虫 简单示例
最新推荐文章于 2021-12-22 14:09:16 发布