The following code throws an error "socket.gaierror: [Errno -2] Name or service not known".
import httplib, urllib
attrs = urllib.urlencode({"username":"admin", "password":"admin"})
conn = httplib.HTTPSConnection("https://x.x.x.x:8181开发者_Python百科")
conn.request("POST", "/login", attrs)
response = conn.getresponse()
print response.status, response.reason
I don't want to use urllib2 module. Could anybody help me?... How to save the state of that server?, so that next time i directly post the values for the uri.
I think you are not specifying the non-default port correctly: http://docs.python.org/release/2.6.7/library/httplib.html#httplib.HTTPSConnection
Try this instead:
conn = httplib.HTTPSConnection("https://x.x.x.x",port=8181)
Try the following code:
conn = httplib.HTTPSConnection("x.x.x.x",port=8181)
I was getting a similar error with httplib.HTTPConnection, I found changing the url from "http://x.x.x.x" to "x.x.x.x" worked for me. Try removing the "http://" or "https://".
conn = httplib.HTTPSConnection("x.x.x.x:8181")
精彩评论