Python 中的 RSS 提要解析器库 [英] RSS feed parser library in Python

查看:47
本文介绍了Python 中的 RSS 提要解析器库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个很好的 Python 库,可以帮助我解析 RSS 提要.有人用过feedparser吗?有什么反馈吗?

I am looking for a good library in python that will help me parse RSS feeds. Has anyone used feedparser? Any feedback?

推荐答案

使用 feedparser比使用 minidom 或 BeautifulSoup 自己动手做更好的选择.

Using feedparser is a much better option than rolling your own with minidom or BeautifulSoup.

  • 它规范了所有版本的 RSS 和 Atom 之间的差异,因此您不必为每种类型编写不同的代码.
  • 检测 Feed 中的不同日期格式和其他变体非常有用.
  • 它会自动跟随 HTTP 重定向.
  • 它可以清理 HTML 内容.
  • 它支持 ETag 和 Last-Modified 标头,因此您可以通过下载 HTTP 标头而不是整个提要来查看提要是否已更改.
  • 它支持经过身份验证的供稿.
  • 它支持 HTTP 代理.

就像其他人提到的那样,试试吧.解析提要就像两行代码.我唯一的抱怨是它只使用字典作为其数据模型,如果某些属性不在提要中,则字典中可能会丢失它们,因此您必须在代码中进行检查.但是文档非常清楚哪些属性将始终在字典中,哪些可能会丢失.

Like others have mentioned, just try it. It's like 2 lines of code to parse a feed. My only complaint is that it just uses dictionaries as its data model and some attributes can be missing from the dictionary if they weren't in the feed, so you have to check for that in your code. But the documentation is very clear on which attributes will always be in the dictionary and which might be missing.

最后,我可以保证它,因为我已经编写了一个使用它的应用程序.请参阅此处:http://www.feednotifier.com/

Finally, I can vouch for it, as I've written an application that uses it. See here: http://www.feednotifier.com/

这篇关于Python 中的 RSS 提要解析器库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆