[BangPypers] automate logging (Pythonic)
Anand Balachandran Pillai
abpillai at gmail.com
Thu Jul 24 13:46:09 CEST 2008
Don't bother with password managers. For HTTP basic authentication,
the quickest way is to add the auth header yourself. Here is the code.
>>> import urllib2, base64
>>> r = urllib2.Request('http://www.tek-tips.com')
>>> auth=base64.encodestring('%s:%s' % ('johnny','yesyes')
>>> r.add_header('Authorization','Basic %s' % auth)
<addinfourl at 2145898156 whose fp = <socket._fileobject object at 0x7ff35304>>
On Thu, Jul 24, 2008 at 5:05 PM, Vijay Ramachandran <vijay750 at gmail.com> wrote:
> On 7/24/08, bangpypers-request at python.org <bangpypers-request at python.org>
>> From: Pythonic <pythonic at gmail.com>
>> Subject: Re: [BangPypers] automate logging
>> To: leo_365 at yahoo.com, Bangalore Python Users Group - India
>> leo davis wrote:
>> > Hello,
>> > I'm trying to write a code to automate logging into a website.I have
>> > chosen the forum 'www.tek-tips.com' as an example and tried this
>> > script on it....But it doesnt seem to work...What am i missing
>> > here..plz help
>> > theurl = 'www.tek-tips.com'
>> > protocol = 'http://'
>> > username = 'johnny'
>> > password = 'yesyes'
>> > passman.add_password(None, theurl, username, password)
> change "theurl" to contain the protocol as well, i.e., instead of the above,
> passman.add_password(None, protocol + thurl, username, password)
> If it works - don't ask me why! I ran into the same problem, and discovered
> this through trial and error.
> BangPypers mailing list
> BangPypers at python.org
More information about the BangPypers