请问会有线上直播或者回放吗?
试试使用基于 Ruby 3 新特性的 Fiber 调度器 https://github.com/bruno-/fiber_scheduler
require 'fiber_scheduler'
require 'net/http'
require 'nokogiri'
require 'benchmark'
Fiber.set_scheduler(FiberScheduler.new)
begin_time = Time.now
uri = URI('http://www2.kugou.kugou.com/yueku/v8/album/index/getData.js')
referrer_policy="http://www2.kugou.kugou.com"
number = 1
(1..200).each do |i|
Fiber.schedule do
params = { :cdn => "cdn", :l => 1, :p => i, :c => 0 }
uri.query = URI.encode_www_form(params)
res = Net::HTTP.get_response(uri)
puts res.body
end
end
end_time = Time.now
puts "Time taken is #{end_time - begin_time}."
还有一个也可供楼主参考,Linux 下自带的命令行工具普遍遵循 KISS 原则:即每个工具只完成一个简单功能,复杂功能由管道组合多个简单工具完成