Created
March 20, 2012 08:17
-
-
Save conmame/2132731 to your computer and use it in GitHub Desktop.
open t.co url
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
# -*- encoding: utf-8 -*- | |
require "net/http" | |
require "uri" | |
class OpenTcoUrl | |
def initialize; end | |
def open_tco_url tco_url | |
result = [] | |
tco_url.each do |t| | |
next unless t =~ /^http:\/\/t.co\/.*$/ | |
uri = URI.parse(t) | |
Net::HTTP.start(uri.host, uri.port){|http| | |
header = { | |
"user-agent" => "Ruby/#{RUBY_VERSION} open t.co" | |
} | |
response = http.head(uri.path, header) | |
result << response["location"] | |
} | |
end | |
result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
t = OpenTcoUrl.new
full_url = t.open_tco_url ARGV
ruby fileName.rb http://t.co/hogehoge http://t.co/hoge ...