开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜