Hi, all... I used to use "feedtools" (now defunct) and I am trying to switch over to the RSS stdlib. Can anyone tell me why this doesn't work? (Error below) Thanks, Hal require 'rss' require 'open-uri' URL = "http://feeds.space.com/SpacecomUniversalSpacePodcast" rss = open(URL).read feed = RSS::Parser.parse(rss) puts "Description: #{feed.title}" feed.items.each.with_index {|item,i| puts "#{i+1}. #{item.title}" } Error is: /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/2.0.rb:53:in `rescue in pubDate=': value <Thu, 05 July 2007 4:00:00 GMT> of tag <pubDate> is not available. (RSS::NotAvailableValueError) from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/2.0.rb:50:in `pubDate=' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/parser.rb:456:in `block in start_get_text_element' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/parser.rb:358:in `call' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/parser.rb:358:in `tag_end' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rexml/parsers/streamparser.rb:26:in `parse' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rexml/document.rb:243:in `parse_stream' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/rexmlparser.rb:22:in `_parse' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/parser.rb:164:in `parse' from /Users/Hal/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rss/parser.rb:79:in `parse'
on 2013-03-19 22:48
on 2013-03-20 01:49
Hi, In <CACrXA6XftYNTf1NkybyBq-f0xHwTUUNrZKqx-gp5NDmMOihhGg@mail.gmail.com> "RSS standard lib?" on Wed, 20 Mar 2013 06:47:35 +0900, Hal Fulton <rubyhacker@gmail.com> wrote: > I used to use "feedtools" (now defunct) and I am trying to switch over > to the RSS stdlib. > > Can anyone tell me why this doesn't work? (Error below) ... > require 'rss' > require 'open-uri' > > URL = "http://feeds.space.com/SpacecomUniversalSpacePodcast" > > rss = open(URL).read > feed = RSS::Parser.parse(rss) > puts "Description: #{feed.title}" > feed.items.each.with_index {|item,i| puts "#{i+1}. #{item.title}" } Try the following: require 'rss' require 'open-uri' URL = "http://feeds.space.com/SpacecomUniversalSpacePodcast" rss = open(URL).read feed = RSS::Parser.parse(rss, false) puts "Description: #{feed.channel.title}" feed.items.each.with_index {|item,i| puts "#{i+1}. #{item.title}" } Points: * Add false argument to RSS::Parser.parse as the second argument. It means "the parser doesn't validate value". * Change "feed.title" to "feed.channel.title". /rss/channel/title is the title of the feed in RSS 2.0. Thanks,
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.