require 'net/http'
urls = [
{'link' => 'http://www.google.com/'},
{'link' => 'http://www.yandex.ru/'},
{'link' => 'http://www.baidu.com/'}
]
urls.each do |u|
u['content'] = Net::HTTP.get( URI.parse(u['link']) )
end
print urls
This code works in synchronous style. First request, second, third. I would like to send all requests asynchronously and print urls
after all of them is done.
What the best way to do it? Is Fiber suited for that?