简体   繁体   中英

Parsing Atom & RSS in Ruby/Rails?

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?

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. :)

Googleage reveals some things. Were they not acceptable?

Simple RSS
Ruby-Feedparser

require 'simple-rss'
require 'open-uri'
rss = SimpleRSS.parse open('http://slashdot.org/index.rdf')
rss.channel.title # => "Slashdot"

如果遇到糟糕的Feed,您可能需要使用HPricot来解析Feed。

看起来在2009年, 标准的Ruby RSS库还不存在吗?

Feed Normalizer looks like it may be a good option

https://github.com/aasmith/feed-normalizer

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

I have tried Feedzirra and SimpleRSS and I found that both work great. Feedzirra was faster though so if its performance you're looking for, you're better off with Feedzirra.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM