爬虫学习笔记--爬取百度贴吧
来源:互联网 发布:辅导软件 编辑:程序博客网 时间:2024/05/18 10:47
由于松爱协会小伙伴的邀请 我把贴吧里的一些诗集整理了一下
用爬虫爬取下来
由于是静态的 不需要用到selenuim
就直接贴代码了
#coding=utf-8import requestsfrom bs4 import BeautifulSoupimport sysimport timereload(sys)sys.setdefaultencoding('utf-8')link = "https://tieba.baidu.com/p/4877675324"link2 = "https://tieba.baidu.com/p/4877675324?pn=2"headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'}r = requests.get(link,headers=headers)r2 = requests.get(link2,headers=headers)soup = BeautifulSoup(r.text,"html.parser")soup2 = BeautifulSoup(r2.text,"html.parser")content_list = soup.find_all("div",class_ = "d_post_content j_d_post_content ")content_list2 = soup2.find_all("div",class_ = "d_post_content j_d_post_content ")for i in range(len(content_list)): conent = content_list[i].text.strip() print ("诗集"+str(i+1)+":") print (conent)for j in range(len(content_list2)): conent2 = content_list2[j].text.strip() print ("诗集"+str(i+j+1)+":") print (conent2)
阅读全文
0 0
- 爬虫学习笔记--爬取百度贴吧
- python学习笔记之爬虫之爬取百度贴吧某一帖子
- python爬虫学习笔记2——百度贴吧帖子爬取
- 简单爬虫爬取百度贴吧
- python网络爬虫学习(二)一个爬取百度贴吧的爬虫程序
- Python爬虫urllib笔记(四)之使用BeautifulSoup爬取百度贴吧
- python爬虫学习-爬取百度贴吧图片并保存
- Python简单爬虫,爬取百度贴吧
- python爬虫爬取百度贴吧的信息
- Python3 简单爬虫爬取百度贴吧帖子
- Python爬虫爬取百度贴吧多线程版
- Python爬虫实战之爬取百度贴吧帖子
- python爬虫小项目: 爬取百度贴吧帖子
- python爬虫小项目:爬取百度贴吧图片
- python爬虫(13)爬取百度贴吧帖子
- Python爬虫实例--爬取百度贴吧小说
- python爬虫入门:2--爬取百度贴吧内容
- Python简单爬虫开发的学习笔记整理(爬取百度百科词条)
- Struts2 ognl判断集合对象是否为空的方法
- 微信“15。。。。。”背后的故事
- 【设计模式】工厂模式——创建对象的最佳方式
- electron 下载文件功能
- hdu 1014 最大公约数
- 爬虫学习笔记--爬取百度贴吧
- 剑指offer第17题(树的子结构)
- 第八章 Android开发规范整理以及Strings.xml定义规范化
- java-web项目的分页与联合模糊查询(不使用分页框架)
- 知识点摘要
- 内轮差编辑内轮差
- PHP中图片上传
- AndroidStudio上传项目到Bintray jCenter
- Cocos Creator Tiledmap——入门知识整理