require 'typhoeus' | |
def download_typhoeus(urls, concurrency) | |
hydra = Typhoeus::Hydra.new(max_concurrency: concurrency) | |
urls.each do |url| | |
request = Typhoeus::Request.new url | |
request.on_complete do |response| | |
write_file url, response.body | |
end | |
hydra.queue request | |
end | |
hydra.run | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment