Created
March 23, 2009 16:09
-
-
Save peterc/83625 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/ruby | |
# Fetch Jakob Nielsen's Alertbox and turn it into a basic RSS feed | |
%w{rubygems hpricot open-uri rss/maker}.each { |l| require l } | |
puts "Content-type: text/xml\n\n" | |
feed = RSS::Maker.make("2.0") do |rss| | |
rss.channel.title = "Jakob Nielsen's Alertbox" | |
rss.channel.link = "http://useit.com/alertbox" | |
rss.channel.description = "Jakob Nielsen's Alertbox" | |
(Hpricot(open('http://www.useit.com/alertbox')) / "li a").first(10).each do |link| | |
item = rss.items.new_item | |
item.title = link.inner_text | |
item.link = "http://www.useit.com/alertbox/" + link.attributes['href'] | |
end | |
end | |
puts feed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment