Created
May 15, 2011 20:43
-
-
Save lukaszsagol/973516 to your computer and use it in GitHub Desktop.
typhoeus example
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
hydra = Typhoeus::Hydra.new :max_concurrency => 5 | |
urls = %w(http://www.google.com/ http://engadget.com/ | |
http://rubyonrails.org/ http://railscasts.com/) | |
responses = [] | |
urls.each do |url| | |
req = Typhoeus::Request.new url | |
req.on_complete do |resp| | |
if resp.success? | |
responses << resp.body | |
else | |
responses << "#{url} failed with #{resp.code}" | |
end | |
end | |
hydra.enqueue req | |
end | |
hydra.run # let the magic begin! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment