第四课 Python爬虫简单爬取新浪新闻列表
来源:互联网 发布:怎样做网络推广赚钱 编辑:程序博客网 时间:2024/05/29 10:39
新闻列表页网页结构:
输出h2:
res = requests.get('http://news.sina.com.cn/china/')
res.encoding = 'utf-8'
soup = BeautifulSoup(res.text,'html.parser')
for news in soup.select('.news-item'):
if( len(news.select('h2')) >0 ):
print(news.select('h2')[0])
.text
如法炮制:
获取新闻时间标题超链接
res = requests.get('http://news.sina.com.cn/china/')
res.encoding = 'utf-8'
soup = BeautifulSoup(res.text,'html.parser')
for news in soup.select('.news-item'):
if( len(news.select('h2')) >0 ):
h2 = news.select('h2')[0].text
time = news.select('.time')[0].text
a = news.select('a')[0]['href']
print(time,h2,a)
注:本文属于原创文章,转载请注明本文地址!
作者QQ:1099718640
CSDN博客主页:http://blog.csdn.net/dyboy2017
Github开源项目:https://github.com/dyboy2017/spider
阅读全文
0 0
- 第四课 Python爬虫简单爬取新浪新闻列表
- 使用python网络爬虫爬取新浪新闻(一)
- Python爬取新浪新闻
- 爬虫第四课(RegEx爬取新闻网站)
- Python爬虫学习(一)——爬取新浪新闻
- python3爬虫-爬取新浪新闻首页所有新闻标题
- Python爬虫爬取网站新闻
- python爬虫爬取Bloomberg新闻
- python爬虫之爬取腾讯新闻
- 第五课 Python爬虫抓取新浪新闻的内容页
- 第六课 Python新浪新闻爬虫最终整理总结
- python爬取新浪新闻存储到excel
- [python爬虫]使用Python爬取网易新闻
- python_爬取新浪新闻
- Python爬虫:抓取新浪新闻数据
- 第一个python爬虫 抓取新浪新闻
- python爬虫之获取新浪新闻信息
- (6)Python爬虫——爬取中新网新闻
- mysql删除语句大全(下)
- HashMap与HashTable的区别 |HashSet和HashMap的区别
- [转载]文华财经中设置倒置的k线方法
- Android中onInterceptTouchEvent、dispatchTouchEvent及onTouchEvent的调用顺序及内部原理
- 技术知识图谱
- 第四课 Python爬虫简单爬取新浪新闻列表
- C语言包含头文件时用引号和尖括号的区别
- vue中使用MD5加密
- CentOS7.2 nginx和uwsgi部署django项目步骤:
- Ubuntu Pycharm不能同时选中多行解决方法
- UVA 10004
- Top命令参数学习
- java ajaxfileupload 文件上传
- matplotlib 画图