In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
What are Cookie and Session crawlers in Python? for this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
About cookie and session, it is estimated that many programmers will be asked during the interview, these two concepts will be involved in writing web and crawlers, and the two may not be particularly clear for many people to answer directly, so collating such an article will also help you deepen your understanding.
What is Cookie?
To put it simply, when a user accesses a server through the http protocol, the server will return some Name/Value key-value pairs to the client browser and impose some restrictions on the data. When the conditions are met, the next time the user visits the server, the data is fully brought to the server.
Because http is a stateless protocol, the server knows nothing about the user when the user first visits the web site. Cookie is like a label that the server attaches to each user who comes to visit, and these tags are an identification of the unique identity of the client that comes to visit, just like everyone's ID card, with your personal information. When a client connects to him for the first time, the server will give him a tag, which is like sending you an ID card. When you download and bring this ID card, the server will know who you are. So Cookie exists on the client side, and it's actually in your browser.
Cookie contains an arbitrary list of information such as name = value (name=value), which is posted to the client through the Set-Cookie or Set-Cookie2HTTP response (extension) header.
In fact, there is a very typical application here, which is about the account information of you logging on many websites. After you let you remember the password, you do not need to enter the password for a period of time. Every time you log in.
Classification of Cookie
Here there are two main types of Cookie:
Session Cookie: do not set the expiration time, save it in the browser's memory, close the browser, and the Cookie will be destroyed
Normal Cookie: set the expiration time and save it on the hard disk
Cookie attribute
Because the original cookie is defined by Netscape, and then there is the RFC version, so there are two versions of the current Cookie: Version0Version1, they have two kinds of logos to set the response header, which are: Set-Cookie and Set-Cookie2, which also makes some properties different. It should be noted here that the commonly used one is Version0.
Properties of Version0
NAME=Value: the key-value pair sets the Name/Value to be saved. The name here cannot drink the same names as other attributes.
Expires: expiration time
Domain: the domain name that generated the Cookie
Path: under which path is the Cookie generated?
Secure: if this property is set, the Cookie will only be returned when the SSH is connected
Properties of Version1
Name=VALUE: the key-value pair sets the Name/Value to be saved. The name here cannot drink the same names as other attributes.
Comment: the main idea is to explain the purpose of the Cookie.
CommentURL: the server provides URI comments for this COokie
Discard: whether to discard the Cookie at the end of the reply. Default is false.
Domain: the domain name that generated the Cookie
Max-Age: the maximum failure time, unlike Version0, is the number of seconds after which it is set to expire.
Path: under which path is the Cookie generated?
Port: under which port can the Cookie be sent back to the server? if there are multiple ports, separate them with commas.
Secure: if this property is set, the Cookie will only be returned when the SSH is connected
This is the answer to the question about what Cookie and Session crawlers are in Python. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.