cookielib Example

Category: Python - Miscellaneous

cookielib is a library new to Python 2.4
Prior to Python 2.4 it existed as ClientCookie, but it's not a drop in replacement - some of the function of ClientCookie has been moved into urllib2.

This example shows code for fetching URIs (with cookie handling - including loading and saving) that will work unchanged on :
a machine with python 2.4 (and cookielib)
a machine with ClientCookie installed
a machine with neither
(Obviously on the machine with neither the cookies won't be handled or saved).

Where either cookielib or ClientCookie is available the cookies will be saved in a file.
If that file exists already the cookies will first be loaded from it.
The file format is a useful plain text format and the attributes of each cookie is accessible in the Cookiejar instance (once loaded).

This may be helpful to those just using ClientCookie as the ClientCookie documentation doesn't appear to document the LWPCookieJar class which is needed for saving and loading cookies. Date: 22 February, 2012


Web

Homepage: http://code.activestate.com/recipes/302930-cookielib-example/?in=lang-python

Developer: Michael Foord

License: Python License

Operating System: Windows

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

Apache is a powerful, flexible, web server.

developer Developer: The Apache Software Foundation
license License: Apache License
operating systems Operating System: daemon


Web-based software for submission and review of papers to academic conferneces.

developer Developer: Shai Halevi
license License: Common Public License
operating systems Operating System: All


Platform for PHP which has gambArt GUI framework for standalone desktop application development, Semok web application framework, and classes collection (distributed computing, networking, compression, byte compiler, SMS, XML, and database abstraction).

developer Developer: Reza Iqbal
license License: Common Public License
operating systems Operating System: Linux, Windows


Free application that allows you to play music on your website.

developer Developer: Andrey Markin
license License: Freeware
operating systems Operating System: Not Available


Another amazing Script from Dr.

developer Developer: Dr.Surajit Sarkar
license License: Freeware
operating systems Operating System: Unix,Linux,Windows


Pheap offers a simple, bold interface that masks a powerful content management system.

developer Developer: Spencer Akers
license License: Freeware
operating systems Operating System: ALL


dhtmlxToolbar is a free JavaScript Toolbar with high functionality, XML support, cross-browser compatibility and rich API.

developer Developer: Ivan Petrenko
license License: Freeware
operating systems Operating System: Win 9x, Win ME, WinNT, Windows 2000, Win XP, Windows 2003, Unix, Linux, Mac OS X, Mac Other


Another way to read lines from file backwards from the end to the beginning.

developer Developer: Andrew Dalke
license License: Python License
operating systems Operating System: Windows


Below you will find a simple python class that I wrote to test performance of
various different sorting techniques.

developer Developer: John Nielsen
license License: Python License
operating systems Operating System: Windows