【AMAD】python-goose -- HTML Content/Article 提取器

动机

新闻网页,结构大多是类似的。

所以,能不能用一种通用的爬取方法来提取其中的数据?

简介

Goose最初是一个Java项目,在2011年被转为了scala项目1.

Py-goose2是使用python重写的版本。这个软件的主要目的不仅是提取一个 新闻/文章 页面的主要文本,而且会试着提取它所有的元数据以及图片数据。

值得一提的是,py-goose相对于newspaper3,多支持了很多不同语言的网页:

  • spanish
  • chinese
  • arabic
  • korean

用法

>>> from goose import Goose
>>> url = 'http://edition.cnn.com/2012/02/22/world/europe/uk-occupy-london/index.html?hpt=ieu_c2'
>>> g = Goose()
>>> article = g.extract(url=url)
>>> article.title
u'Occupy London loses eviction fight'
>>> article.meta_description
"Occupy London protesters who have been camped outside the landmark St. Paul's Cathedral for the past four months lost their court bid to avoid eviction Wednesday in a decision made by London's Court of Appeal."
>>> article.cleaned_text[:150]
(CNN) -- Occupy London protesters who have been camped outside the landmark St. Paul's Cathedral for the past four months lost their court bid to avoi
>>> article.top_image.src
http://i2.cdn.turner.com/cnn/dam/assets/111017024308-occupy-london-st-paul-s-cathedral-story-top.jpg

个人评分

类型评分
实用性⭐️⭐️
易用性⭐️⭐️⭐️
有趣性⭐️⭐️⭐️⭐️

转载于:https://www.cnblogs.com/thomaszdxsn/p/amadpythongoose--html-contentarticle-ti-qu-qi.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值