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
精彩评论