我正在尝试使用 HTTP POST-request 将两个参数发布到http://foo.bar.com/submit.jsp。
这行得通。
conn = httplib.HTTPConnection("www.bar.com")
conn.request("POST", "",parameters)
但这不是,有人可以向我解释为什么它没有以及正确的方法是什么?
conn = httplib.HTTPConnection("www.foo.bar.com")
conn.request("POST", "/submit.jsp", parameters)
我收到此错误
File "example.py", line 68, in <module>
conn.request("POST", "/submit.jsp", parameters)
File "/usr/lib/python2.7/httplib.py", line 958, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 814, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 776, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 757, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known
提前致谢