Python cookielib module for operating cookies

大家讲道理
Release: 2016-11-07 10:52:23
Original
1653 people have browsed it

Cookielib is a module that automatically handles cookies. If we need to save cookies when using technologies such as crawlers, cookielib will allow you to get twice the result with half the effort! His most common partner modules are urllib and request under python.

Core Class

1. Cookie

This class implements the cookie standard defined by Netscape and RFC 2965 cookies, and can basically be understood as a certain piece of cookie data.

Part of the code is as follows. Do many attributes look familiar?

    self.domain_initial_dot = domain_initial_dot
    self.path = path
    self.path_specified = path_specified
    self.secure = secure
    self.expires = expires
    self.discard = discard
    self.comment = comment
    self.comment_url = comment_url
    self.rfc2109 = rfc2109
Copy after login

2.CookiePolicy

The main function of this class is to send and receive cookies, that is, to ensure that the correct cookie is sent to the corresponding domain name, and vice versa.

3.DefaultCookiePolicy

This class implements the CookiePolicy interface.

4.CookieJar

CookieJar is a collection of cookies, which can contain many Cookie classes and is our main operation object. There are a series of methods to support more detailed operations!

5.FileCookieJar

This class inherits from CookieJar. CookieJar only completes its life cycle in memory. The subclass of FileCookieJar can achieve data persistence and defines three interfaces: save, load, and revert.

6. MozillaCookieJar & LWPCookieJar

Two implementation classes, the inheritance relationship is as follows:

Python cookielib module for operating cookies

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!