Created
August 30, 2013 08:52
-
-
Save Usse/6387770 to your computer and use it in GitHub Desktop.
Latest HN titles in the console!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rss/1.0' | |
require 'rss/2.0' | |
require 'open-uri' | |
source = "https://news.ycombinator.com/rss" | |
content = "" | |
open(source) do |s| | |
content = s.read | |
end | |
rss = RSS::Parser.parse(content, false) | |
print "\n\n", rss.channel.title, "\n\n" | |
n = 0 | |
while(n < rss.items.size) do | |
puts "#{n+1} :\t#{rss.items[n].title}" | |
n +=1 | |
end | |
#puts "Item values" | |
#print "number of items: ", rss.items.size, "\n" | |
#print "title of first item: ", rss.items[0].title, "\n" | |
#print "link of first item: ", rss.items[0].link, "\n" | |
#print "description of first item: ", rss.items[0].description, "\n" | |
#print "date of first item: ", rss.items[0].date, "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment