Making multiple HTTP requests asynchronously

后端 未结 8 1167
傲寒
傲寒 2020-12-13 21:44
require \'net/http\'

urls = [
  {\'link\' => \'http://www.google.com/\'},
  {\'link\' => \'http://www.yandex.ru/\'},
  {\'link\' => \'http://www.baidu.com/\'}
]

ur         


        
8条回答
  •  天命终不由人
    2020-12-13 22:27

    You could have a different thread execute each one of the Net::HTTP.get. And just wait for all the threads to finish.

    BTW printing urls will print both the link and the content.

提交回复
热议问题