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

Steve Holden steve at holdenweb.com
Thu Mar 4 11:32:11 EST 2010


Karen Wang wrote:
> 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 ?
>Read the HTTP standard. The authentication data has to be send as HTTP
headers, not as the data to a POST request. The dialog box you see is
the browser attempting to collect the data it needs to put in the header.
regards
 Steve
-- 
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /