Skip to content

Instantly share code, notes, and snippets.

@peterc
Created January 9, 2009 19:25
Show Gist options
  • Save peterc/45229 to your computer and use it in GitHub Desktop.
Save peterc/45229 to your computer and use it in GitHub Desktop.
# Script to generate a CSV of all your Twitter followers screen_name, name, url, and description (bio)
# Runs fine on OS X: put into a file, and then from a Terminal: ruby whatever.rb to run.
require 'json'
puts "Enter your Twitter username:"
username = gets.chomp
puts "Enter your Twitter password:"
password = gets.chomp
mydata = `curl -XPOST -A "Twitterrific3.1 CFNetwork/422.11 Darwin/9.6.0 (i386) (MacPro3%2C1)" http://#{username}:#{password}@twitter.com/users/show/#{username}.json`
mydata = JSON.parse(mydata)
follower_count = mydata["followers_count"]
print "You have #{follower_count} followers. Fetching"
followers = []
1.upto((follower_count / 100) + 1) do |page_num|
followers += JSON.parse(`curl -XPOST -A "Twitterrific3.1 CFNetwork/422.11 Darwin/9.6.0 (i386) (MacPro3%2C1)" http://#{username}:#{password}@twitter.com/statuses/friends.json?page=#{page_num}`)
end
followers.each do |follower|
puts %Q{"#{follower["screen_name"]}","#{follower["name"].to_s.strip}","#{follower["url"]}","#{follower["description"].to_s.gsub(/\"/, '\"')}"}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment