Using Python 2.1 to download asp www pages that require cookies : My solution

Zugz zugz.public at
Fri Jan 18 09:45:14 EST 2002

"bernie" <bernie at> wrote in message
news:3C480677.987A7334 at
> Hi Zugu,
> This is the case where you cannot just use urllib.urlopen.  The page you
> trying to get is actually sending you a session cookie and excepted you to
> send that cookie to it when you try to get the page.
> The following code should work:
> import urllib
> class AppURLopener( urllib.FancyURLopener):
>     def __init__( self, cookie=None, *args):
>         apply( urllib.FancyURLopener.__init__, (self,) + args)
>         if cookie:
>             self.addheader( "Cookie", cookie)
> urllib._urlopener = AppURLopener( _cookie)
> print

Hi bernie,

Thanks for the solution, it's shorter and more to the point than the
solution I found elsewhere.
Now I just have to puzzle out why it works :)

Thanks again,

More information about the Python-list mailing list