Skip to content

Instantly share code, notes, and snippets.

@russ
Created November 8, 2015 22:45
Show Gist options
  • Save russ/5f7557c131cc73476abf to your computer and use it in GitHub Desktop.
Save russ/5f7557c131cc73476abf to your computer and use it in GitHub Desktop.
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