https post request
Travis Altman
travisaltman at gmail.com
Sat Jun 13 16:05:32 EDT 2009
i'm trying to make a https post request, i'm following the example linked
below.
http://www.java2s.com/Tutorial/Python/0420__Network/SendinganHTTPPOSTRequestfromaPythonScript.htm
i'm trying to make the https post request to netflix.com, below is my code
1 import httplib
2
3 # def statement used to parse response from web server
4 def printText(txt):
5 lines = txt.split('\n')
6 for lines in lines:
7 print line.strip()
8
9 # connect to web server
10 httpServ = httplib.HTTPSConnection("https://www.netflix.com", 443)
11 print httpServ
12 httpServ.connect()
13
14 # specifying the exact login URL
15
16 request = "test"
17
18 httpServ.request('POST', \
19 '/Login', \
20 'nextpage=http%3A%2F%2Fwww.netflix.com
%2F&SubmitButton=Click+Here+to+Continue&movieid=&trkid=&email=email%
40gmail.com&password1=supersecret % request')
21
22 # response
23
24 response = httpServ.getresponse()
25
26 print response
27 if response.status == httplib.OK:
28 printText (response.read())
29
30 httpServ.close()
getting the following errors, any suggestions?
Traceback (most recent call last):
File "printerPythonScript.py", line 12, in <module>
httpServ.connect()
File "/usr/lib/python2.5/httplib.py", line 1130, in connect
sock.connect((self.host, self.port))
File "<string>", line 1, in connect
socket.gaierror: (-5, 'No address associated with hostname')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090613/d11ac08e/attachment.html>
More information about the Python-list
mailing list