Skip to content

Instantly share code, notes, and snippets.

@andersonleite
Created December 28, 2010 17:14
Show Gist options
  • Save andersonleite/757424 to your computer and use it in GitHub Desktop.
Save andersonleite/757424 to your computer and use it in GitHub Desktop.
download twitter picture
require 'rubygems'
gem 'twitter'
require 'twitter'
require 'open-uri'
require 'find'
user_name = "anderson_leite"
image_url = Twitter.user(user_name).profile_image_url
image_name = image_url.match(/([\w_]+).(\w\w\w)$/)
file_path = "/Users/andersonleite/Desktop/twimages/#{user_name}.#{image_name[2]}"
unless File.exists?(file_path)
File.open(file_path, 'w') do |output|
open(image_url) do |input|
output << input.read
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment