您当前的位置: 首页 >  Python

Python爬虫:使用newspaper解析新闻页面信息

彭世瑜 发布时间:2019-10-18 14:02:52 ,浏览量:3

github: https://github.com/codelucas/newspaper

安装
pip3 install newspaper3k
代码示例
# -*- coding: utf-8 -*-

from newspaper import Article

url = "https://news.sina.com.cn/"
article = Article(url)
article.download()
article.parse()

print(article.title)
print(article.authors)
print(article.publish_date)
print(article.top_image)
print(article.text[:50])

解析的结果和新闻页面显示的信息基本一致,如果是简单处理新闻应该可以了

关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 3浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.1558s