RSS feed parser library in Python [closed]
Asked Answered
O

8

42

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

Obliging answered 11/2, 2010 at 13:57 Comment(2)
Downloading and trying out feedparser would take 5 minutes.Lafrance
Download and trying out feedparser may only take 5 minutes, but it would take much longer to use it thoroughly enough to form an opinion us useful and reliable as others on SO. 5 minutes of usage would only prove that it can be installed and handle the main use case.Decrescent
F
58

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

  • It normalizes the differences between all versions of RSS and Atom so you don't have to have different code for each type.
  • It's good about detecting different date formats and other variations in feeds.
  • It automatically follows HTTP redirects.
  • It sanitizes HTML content.
  • It has support for ETag and Last-Modified headers so you can see if the feed has changed just by downloading the HTTP header and not the whole feed.
  • It has support for authenticated feeds.
  • It has support for HTTP proxies.

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.

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

Fikes answered 11/2, 2010 at 15:18 Comment(5)
Thanks for your answer!..Yes it is so cool and well defined documentation!..easy to use.!! Your feed notifier is also interesting though!Obliging
Do you know of a library that takes feedparser's output and can turn it back into a feed?Hindi
Currently there's an issue that is kind of bothering me: feedparser appears to fail on 'media:' elements in Flickr feeds. It's really annoying. I've just filed an issue, let's hope I get some workaround soon enough.Freeholder
thanks for the article... can I get the source code of feednotifier??Manzanares
github.com/fogleman/FeedNotifierFikes
T
11

Feedparser is very powerful, configurable and sooo easy to use. A very friendly learning curve, if at all.

Example

Programatically determine how many answers your question has:

easy_install feedparser
python -c 'import feedparser; print len(feedparser.parse("http://bit.ly/c785aj")["entries"])'
Thompson answered 11/2, 2010 at 15:16 Comment(1)
You can use .entries instead of ["entries"] since feedparser uses a customized dictionary that allows attribute access. Easier to type and read.Fikes
M
2

If you want an alternative, try xml.dom.minidom. Like "Django is Python", "RSS is XML".

Messapian answered 11/2, 2010 at 15:1 Comment(1)
No good reason to take this approach when feedparser exists. You'd have to handle differences between RSS and Atom, malformed feeds, various date/timestamp formats, etc.Fikes
S
2

I know this is a very old topic, but for what it worth, I was using feedparser (Universal feed parser) version 5.1.3 and I recently swiched to speedparser (0.1.8) for performance reasons. It has pretty much the same interfaces, but run faster.

I'm using it for an amateur Python-for-Android application and speedparser runs about 5 times faster on my feeds.

Surinam answered 14/8, 2014 at 21:56 Comment(0)
D
1

http://www.feedparser.org/

First hit on G.

Dryasdust answered 11/2, 2010 at 13:59 Comment(4)
Well, he did mention it in the question...Lafrance
Anyway, Do you guys have any idea about other than feedpurser which is easy to use?Obliging
@Obliging no, feedparser is too good, nobody would care about an alternative.Fushih
Feedparser is an awesome library. It has loads of unit tests, and it comes with a wonderful built in library that helps with character encoding detection. It's truly a work of art.Ulrich
W
1

In answer to your followup. You could use BeautifulSoup - but feedparser is much better geared towards RSS handing.

Not to snark - but have you read feedparsers documentation? I don't know how it could be simpler to use.

Waterfront answered 11/2, 2010 at 15:0 Comment(1)
For the benefit of others: feedparser.org has been taken down by Mark Pilgrim. I will be making it available as a part of the next release.Almeta
G
1

As of 2019, atoma is a possible alternative to feedparser, although I have not used it.

Galliard answered 10/8, 2019 at 17:0 Comment(0)
T
-1

I Strongly recommend feedparser.

Thompson answered 11/2, 2010 at 15:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.