【python 爬虫】百度贴吧帖子所有楼层图片爬虫
来源:互联网 发布:java将时间转换成秒 编辑:程序博客网 时间:2024/05/16 12:22
下载百度贴吧帖子图片,好好看
python2.7版本:
#coding=utf-8import reimport requestsimport urllibfrom bs4 import BeautifulSoupimport timetime1=time.time()def getHtml(url): page = requests.get(url) html =page.text return htmldef getImg(html): soup = BeautifulSoup(html, 'html.parser') img_info = soup.find_all('img', class_='BDE_Image') global index for index,img in enumerate(img_info,index+1): print ("正在下载第{}张图片".format(index)) urllib.urlretrieve(img.get("src"),'C:/pic4/%s.jpg' % index)def getMaxPage(url): html = getHtml(url) reg = re.compile(r'max-page="(\d+)"') page = re.findall(reg,html) page = int(page[0]) return pageif __name__=='__main__': url = "https://tieba.baidu.com/p/5113603072" page = getMaxPage(url) index = 0 for i in range(1,page): url = "%s%s" % ("https://tieba.baidu.com/p/5113603072?pn=",str(i)) html = getHtml(url) getImg(html) print ("OK!All DownLoad!") time2=time.time() print u'总共耗时:' + str(time2 - time1) + 's'
阅读全文
1 0
- 【python 爬虫】百度贴吧帖子所有楼层图片爬虫
- 【python爬虫】百度贴吧帖子图片批量保存爬虫
- Python爬虫实战(五) :下载百度贴吧帖子里的所有图片
- Python爬虫实战:百度贴吧帖子
- 爬虫-百度贴吧帖子
- python3 多页爬虫爬取百度贴吧帖子所有图片
- Python爬虫实战(2):百度贴吧帖子
- Python爬虫实战(2):百度贴吧帖子
- Python爬虫实战之爬取百度贴吧帖子
- python爬虫小项目: 爬取百度贴吧帖子
- python爬虫(13)爬取百度贴吧帖子
- Python 爬虫获取百度贴吧图片
- Python爬虫实战(1)——百度贴吧抓取帖子并保存内容和图片
- Python 百度爬虫图片
- demo_4.我的第一个爬虫,爬取百度贴吧中一个帖子的所有.jpg图片
- Python爬虫实战二之爬取百度贴吧帖子
- python学习笔记之爬虫之爬取百度贴吧某一帖子
- python爬虫学习笔记2——百度贴吧帖子爬取
- 【HDU 6198】number number number 【规律+矩阵快速幂】
- CUDA安装后路径不全导致TensorFlow MNIST例子运行中PyThon发生异常
- linux常用命令3
- S3C2440之UART
- TCP三次握手四次挥手——下篇
- 【python 爬虫】百度贴吧帖子所有楼层图片爬虫
- 浙江大华2015面试题
- viewpager切换动画
- 使用 SysRq 查看系统信息
- JAVA面向对象基础学习及笔记
- bzoj1612 [Usaco2008 Jan]Cow Contest奶牛的比赛(Floyd)
- MySQL中join的update、delete语法
- [MSSQL]事务日志还原
- openGL中投影矩阵的推导