Skip to content

Instantly share code, notes, and snippets.

@peterc
Created March 23, 2009 16:09
Show Gist options
  • Save peterc/83625 to your computer and use it in GitHub Desktop.
Save peterc/83625 to your computer and use it in GitHub Desktop.
#!/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