Created
December 28, 2010 17:14
-
-
Save andersonleite/757424 to your computer and use it in GitHub Desktop.
download twitter picture
This file contains 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
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