Ai
1 Star 0 Fork 1

高鑫/Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
news_article.py 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
randerson112358 提交于 2019-07-31 11:16 +08:00 . Update news_article.py
#Description: Scrape and Summarize News Articles
#pip install nltk
#pip install newspaper3k
#Resources: Documenation: https://newspaper.readthedocs.io/en/latest/?source=post_page---------------------------
# Medium Article: https://towardsdatascience.com/scrape-and-summarize-news-articles-in-5-lines-of-python-code-175f0e5c7dfc
# Article Website: https://www.washingtonpost.com/technology/2019/07/17/you-downloaded-faceapp-heres-what-youve-just-done-your-privacy/?noredirect=on&utm_term=.f8b0b55b2805
#Import the libraries
import nltk
from newspaper import Article
#Get the article
url = 'https://www.washingtonpost.com/technology/2019/07/17/you-downloaded-faceapp-heres-what-youve-just-done-your-privacy/?noredirect=on&utm_term=.1938589d078f'
article = Article(url)
# Do some NLP
article.download()
article.parse()
nltk.download('punkt')
article.nlp()
#Get the authors
article.authors
#Get the publish date
article.publish_date
#Get the top image
article.top_image
#Get the article text
print(article.text)
#Get a summary of the article
print(article.summary)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gaoxin1999/Python.git
git@gitee.com:gaoxin1999/Python.git
gaoxin1999
Python
Python
master

搜索帮助