How to login https sever with inputing account name and password?

Karen Wang karen.wang at avant-port.com.cn
Thu Mar 4 05:38:08 EST 2010


Hi all,

I want to use python to access to https server, like
"https://212.218.229.10/chinatest/"

If open it from IE, will see the pop-up login windows like this 



I tried several ways but always only get page for" HTTP Error 401.2 -
Unauthorized" error. ( myusername and mypassword are all correct)

Below is my code:

import urllib2

values = {

    'user' : "myusername", 

"pass' : "mypassword" }

data = urllib2.urlencode(values)

t = urllib2.urlopen('https://212.218.229.10/chinatest/',data)

print t.read()

where I am wrong ?

Thank you very much.

 

 

Best Regards

Karen Wang

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100304/eb98829e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 17890 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20100304/eb98829e/attachment.jpg>


More information about the Python-list mailing list