|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 helehappy 于 2014-5-24 17:34 编辑
总是提示:TypeError: can't use a string pattern on a bytes-like object
import re
import urllib.request
def gethtml(url):
page = urllib.request.urlopen(url)
html = page.read()
return html
def getimg(html):
reg = rb'src="(.*?\.jpg)" pic\_ext'
imgre = re.compile(reg)
imglist = re.findall(imgre,html)
x = 0
for i in imglist:
urllib.request.urlretrieve(i,'%s.jpg' % x)
x+=1
html = gethtml("http://tieba.baidu.com/p/3062452160?pn=1")
getimg(html)
下面是要匹配的下载链接
|
|