Created
October 30, 2009 20:03
-
-
Save TrevorBramble/222662 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'open-uri' | |
require 'simple-rss' | |
if ARGV[0].nil? | |
puts "Provide a Twitter screen name"; exit; | |
else | |
screen_name = ARGV[0] | |
end | |
file = screen_name+'_tweets.txt' | |
fh = File.open(file, "w") | |
url = "http://twitter.com/statuses/user_timeline.atom?"+ | |
"screen_name=#{screen_name}&count=200&page=" | |
iterator = 1 | |
brake = false | |
while true | |
rss = SimpleRSS.parse open( url + iterator.to_s ) | |
rss.channel.items.each do |item| | |
fh.write item.title + "\n" | |
end | |
iterator + 1 | |
if ( rss.channel.items.count < 200 ) then break end | |
end | |
fh.close | |
puts "Wrote as many tweets as I could to #{file}.\n" | |
if (! File.size?(file) ) then File.delete(file) end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment