Chinaunix首页 | 论坛 | 博客
  • 博客访问: 197085
  • 博文数量: 40
  • 博客积分: 2265
  • 博客等级: 大尉
  • 技术积分: 434
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-23 17:01
文章分类

全部博文(40)

文章存档

2014年(1)

2013年(2)

2012年(6)

2011年(5)

2010年(26)

我的朋友

分类: Python/Ruby

2010-09-26 15:47:21

The cookielib module defines classes for automatic handling of HTTP cookies. It is useful for accessing web sites that require small pieces of data - cookies - to be set on the client machine by an HTTP response from a web server, and then returned to the server in later HTTP requests.

The following classes are provided:

class CookieJar( policy=None)
policy is an object implementing the CookiePolicy interface.

The CookieJar class stores HTTP cookies. It extracts cookies from HTTP requests, and returns them in HTTP responses. CookieJar instances automatically expire contained cookies when necessary. Subclasses are also responsible for storing and retrieving cookies from a file or database.

class FileCookieJar( filename, delayload=None, policy=None)
policy is an object implementing the CookiePolicy interface. For the other arguments, see the documentation for the corresponding attributes.

A CookieJar which can load cookies from, and perhaps save cookies to, a file on disk. Cookies are NOT loaded from the named file until either the load() or revert() method is called. Subclasses of this class are documented in section 18.22.2.

ck = cookielib.CookieJar()   通过 这个就可 以实现 请求带过去的COOKIE与发送回来的COOKIE值了。
如何来获取到COOKIE呢?opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(ck))
阅读(3412) | 评论(1) | 转发(0) |
0

上一篇:再论字符集(转)

下一篇:shell 读书笔记

给主人留下些什么吧!~~

chinaunix网友2010-09-27 10:48:51

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com