Twitterのテキストから元の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
require 'twitter-text' | |
require 'net/http' | |
require 'uri' | |
text = "Twitter-text with link" | |
Twitter::Extract.extract_urls text do |url| | |
uri = uri.kind_of?(URI) ? url : URI.parse(url) | |
http = Net::HTTP.new(uri.port,uri.parse) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
http.start do |io| | |
r = io.head(uri.path) | |
puts r['Location'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment