Created
November 8, 2015 22:45
-
-
Save russ/5f7557c131cc73476abf to your computer and use it in GitHub Desktop.
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 "open-uri" | |
def get_site_title(domain) | |
response = open(domain) { |f| f.read } | |
response.match(/<title.*>(.*)<\/title>/i)[1] | |
end | |
threads, titles = [], [] | |
[ "http://google.com", "http://apple.com", "https://facebook.com" ].each do |domain| | |
threads << Thread.new do | |
titles << get_site_title(domain) | |
end | |
end | |
threads.each { |t| t.join } | |
puts titles.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment