HUST16届准毕业生,发奋求职中...
分类: Python/Ruby
2015-05-14 13:49:32
Python中有自带的模块:
可以处理cookie相关的很多事情。
包括
更多详细格式和解释,请直接看下面的代码。
点击(此处)折叠或打开
Python中的cookie的自动处理,比C#好多了。
至少有已有的库可供使用。虽然用法上,需要稍微多多了解后,才知道如何使用的。
更多的解释,可参考官方手册:
比如其中的revert等函数,需要用到的时候,应该会觉得蛮好用的。
Save cookies to a file.
This base class raises NotImplementedError . Subclasses may leave this method unimplemented.
filename is the name of file in which to save cookies. If filename is not specified, self.filename is used (whose default is the value passed to the constructor, if any); if self.filename is None , ValueError is raised.
ignore_discard : save even cookies set to be discarded. ignore_expires : save even cookies that have expired
The file is overwritten if it already exists, thus wiping all the cookies it contains. Saved cookies can be restored later using the load() or revert() methods.