I'm looking for something that will let me parse Atom and RSS in Ruby and Rails. I've looked at the standard RSS library, but is there one library that will auto-detect whatever type of feed it is and parse it for me?
+7
A:
Googleage reveals some things. Were they not acceptable?
require 'simple-rss'
require 'open-uri'
rss = SimpleRSS.parse open('http://slashdot.org/index.rdf')
rss.channel.title # => "Slashdot"
Pistos
2008-10-18 05:09:10
Simple-RSS looked good, but it hasn't been updated in 2 years. Feedparser also looked pretty good but it appears there's no gem and it's an 0.6. I was hoping there'd be something a bit more mature that's generally the standard.
aronchick
2008-10-19 04:17:48
I know how you feel about wanting to use active projects, but if the RSS and RDF specs haven't changed much lately, perhaps these would do the trick. :)
Pistos
2008-10-19 05:23:44
i'll give it a shot with Simple RSS - but it really surprises me that there's not a better solution out there - given how web 2.0-y Ruby/Rails and RSS are you'd think there'd be a nice package combining them.
aronchick
2008-10-20 03:26:32
It's quite possible there is a rails-specific solution. I haven't googled for it, though.
Pistos
2008-10-20 11:13:47
+6
A:
If you meet crappy feeds, you may want to use HPricot to parse the feed.
Thibaut Barrère
2008-10-21 10:44:58
Did you settle on Hpricot, I tried this and had a could not get all the information out of a feed. It did fair better than Nokogiri which could not handle malformed feeds.
Kris
2009-09-03 08:38:50
Well one time or two, Hpricot could not handle some very broken feed but apart from that all the time it's working fine for me.I'm using it for http://www.learnivore.com for instance.
Thibaut Barrère
2009-09-15 15:03:21
it looks like feed-normalizer wraps Simple RSS, from installing it. I just used it to trawl through an OPML file of mixed Rss/Atom feeds - it seemed to be very nicely agnostic, I didn't know or care what it was looking at, which suits me!
Mike Woodhouse
2010-01-21 10:52:56
+6
A:
Feedzirra is one of the better options: http://www.pauldix.net/2009/02/feedzirra-a-ruby-feed-library-built-for-speed.html
Of course, I'm biased since I wrote it. :)
Paul Dix
2009-10-21 19:54:31
I agree. Feedzirra is the best. Really fast. Thanks Paul Dix for this amazing library.
Shripad K
2010-04-18 10:54:05
Unfortunately, as it is, its active support dependency is broken on its latest version (on rails 2.3.8, not 3). Since I'm not using jruby, and this lib uses native extensions, no osgi for me. Too bad, Feedzirra looked promising....
Daniel Ribeiro
2010-07-15 01:44:24
A:
I like using niokrigi or scrapi for parsing the xml in the atom/rss feeds. http://www.rubyinside.com/nokogiri-ruby-html-parser-and-xml-parser-1288.html
CodeJoust
2009-10-21 19:56:51