Login Authentication with cookies...

Ian Bicking ianb at colorstudy.com
Tue Jun 4 01:23:29 EDT 2002


That's a weird little error -- a missing import at the top of
ClientCookie.py ?  Anyway, you could also use HTTPSession, included with
webunit.sf.net.

On Mon, 2002-06-03 at 22:05, chandan wrote:
> Hi.., 
> 
> Problem: - write a python script to access pages that are password
> protected, but DONT return a 401 forbidden code. i.e. Login to a
> website like hotmail and check you mail message or in my particular
> case, http://www.fool.com/login.asp
> and then download the discussion board messages for a particular
> stock.
> 
> Attempts so far: - The login and password protection is based on
> cookies, so I used ClientCookie.py as follows (although, i am not sure
> how to use it properly)
> 
> import ClientCookie
> import urllib2
> import urllib
> params = urllib.urlencode({'login':'login','password':'password'})
> request = urllib2.Request("http://www.fool.com/login.asp", params)
> # note we're using the urlopen from ClientCookie, not urllib2
> result = ClientCookie.urlopen(request)
> 
> Error message: 
> Traceback (innermost last)
>   File "c:\python22\programs\demos\trial", line 7, in ?
>     result = ClientCookie.urlopen(request)
> NameError: global name 'types' is not defined
> 
> Program disconnected.
> 
> I dunno what to do about the types in ClientCookie.py... even the
> example code given in the README file for this library returns the
> same error.., i am using windows XP, python 2.2
> 
> ClientCookie can be obtained from here -
> http://wwwsearch.sourceforge.net/ClientCookie/
> 
> Thanx for the help
> Chandan
> 
> P.S : Newbie...
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 







More information about the Python-list mailing list