在ruby中发送POST?

任何好的库在ruby中发送POST头?

你可以这样做……

require 'net/http' postData = Net::HTTP.post_form(URI.parse('http://thewebsite.net'), {'postKey'=>'postValue'}) puts postData.body 

标准库Net :: HTTP非常简单,可以处理POST

来自文档:

 response = http.post('/cgi-bin/search.rb', 'query=foo') # using block File.open('result.txt', 'w') {|f| http.post('/cgi-bin/search.rb', 'query=foo') do |str| f.write str end } 

有关如何使用Net :: HTTP的更详细示例,请参阅Github上的August Lilleaas的Net :: HTTP备忘单存储库 。

如上所述的Net::HTTP ,curl包装器Curb或HTTParty 。 根据你想要做的事情,他们可能有点矫枉过正。

Ruby中有很多HTTP库。 有标准的net / http和libcurl绑定 。 但是也有很多高级库来使用ActiveResource和HTTParty等Web服务。 取决于你想做什么。 也许您可以通过更多信息更新您的问题?