热门
最新
红包
立Flag
投票
同城
我的
发布
每日读书打卡
CSDN App 扫码分享
2
点赞
打赏
- 复制链接
- 举报
下一条:
爬取http://tieba.baidu.com/p/2460150866里面的内容import urllib.requestimport reimport osimport urllibdef getHtml(url): page = urllib.request.urlopen(url) html = page.read() return html.decode('UTF-8') def getImg(html): reg = r'src="(.+?\.jpg)" pic_ext' imgre = re.compile(reg) imglist = imgre.findall(html) x = 0 path = 'D:\\test' if not os.path.isdir(path): os.makedirs(path) paths = path+'\\' for imgurl in imglist: urllib.request.urlretrieve(imgurl,'{}{}.jpg'.format(paths,x)) x = x + 1 return imglisthtml = getHtml("http://tieba.baidu.com/p/2460150866")print (getImg(html)) 'D:\\test'自定义即可