Skip to content

Instantly share code, notes, and snippets.

@lukaszsagol
Created May 15, 2011 20:43
Show Gist options
  • Save lukaszsagol/973516 to your computer and use it in GitHub Desktop.
Save lukaszsagol/973516 to your computer and use it in GitHub Desktop.
typhoeus example
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