开发者

how to send a post request and get the response in ruby

开发者 https://www.devze.com 2023-01-08 04:01 出处:网络
how to send a post request and get the response in ruby r开发者_Python百科equest is, name=$name_val

how to send a post request and get the response in ruby

r开发者_Python百科equest is,

name=$name_val

URL is http://example.com/a/2

how do i do this in python or ruby?


To do this in python:

import urllib
data = urllib.urlencode({
   "fieldName1" : "Val1", 
   "fieldName2" : "Val2", 
   "fieldName3" : "Val3"
})
f = urllib.urlopen("http://example.com/a/2", data)
html = f.read() # this is the response
0

精彩评论

暂无评论...
验证码 换一张
取 消