This is a tutorial to get ruby working with rss...in style. So I decide I wanted to have one of my LCD monitors to constantly scroll people's names as they died...but how would I achieve this feat? Well with a simple script that called several twitter feeds. At first I tried perl but as I was installing one of the modules I had a really HORRIBLE time trying to get it to work. So what I ended up doing is switching to ruby.* So there are three twitter feeds I choose to use...One was just the feed for #obits, I also wanted to use mydeathspace and the LA Times Obituary account. You can accummulate these feeds by going to search.twitter.com then, searching for something, then clickiing the, "I want the feed for this query" or something like that.
This tutorial assumes you have ruby and gems installed.
So the first thing I had to do was install the module...err gem for rss, for ruby, which is simple enough:
gem install simple-rss
Then I wrote this code I ripped off of about:
#!/usr/bin/env ruby
require 'rubygems'
require 'simple-rss'
require 'open-uri'
rss = SimpleRSS.parse(
open('http://search.twitter.com/search.atom?q=%23obit').read
)
rss.items.each do|i|
puts "Title: #{i.title}"
puts "Link: #{i.link}"
puts "=" * 80
end
Obviously I wasn't happy with that, for one I wanted a slow scroll and I wanted multiple feeds and I wanted it to loop so that it would always be outputting. So I added some sleeps and a loop like so:
#!/usr/bin/env ruby
require 'rubygems'
require 'simple-rss'
require 'open-uri'
loop {
rss = SimpleRSS.parse(
open('http://search.twitter.com/search.atom?q=%23obit').read
)
rss.items.each do|i|
puts "Title: #{i.title}"
puts "Link: #{i.link}"
puts "=" * 80
sleep 1
end
sleep 1
rssTwo = SimpleRSS.parse(
open('http://search.twitter.com/search.atom?q=+from%3Amydeathspace').read
)
rssTwo.items.each do|i|
puts "Title: #{i.title}"
puts "Link: #{i.link}"
puts "=" * 80
sleep 1
end
sleep 1
rssThree = SimpleRSS.parse(
open('http://search.twitter.com/search.atom?q=+from%3Alatimesobits').read
)
rssThree.items.each do|i|
puts "Title: #{i.title}"
puts "Link: #{i.link}"
puts "=" * 80
sleep 1
end
sleep 1
}
And there you go, now I have a monitor that basically let's me watch people die.....I am so happy.
*BTW if you are a perl guru and know how I can fix my UserAgent stuff, with a parse_head error, it would be awesomely cool if you could help me out.
3 comments:
Video is set to private brah
Now I know what morbidly obese refers to
About LWP: try installing new version. In general, it is good to report errors to bug tracker.
Post a Comment