Ruby 使用 POST 方法提交数据: set_form_data

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require 'net/http'

url = URI.parse('http://www.rubyinside.com/test.cgi')

Net::HTTP.start(url.host, url.port) do |http|
  req = Net::HTTP::Post.new(url.path)
  req.set_form_data({ 'name' => 'David', 'age' => '24' })
  puts http.request(req).body
end