There is a cookielib package in python that can obtain cookies. The first visit is without cookies~~ The following is a test using firebug: Since I have visited it before, there are cookies for this website on the browser, so clear them.
Visiting again at this time is the real first visit. If you visit again at this time, the packet capture is as follows:
The website will return set-cookie in the request for the first visit. The browser will store the set-cookie, and the cookie value will be brought with it when you visit it in the future. So~ There is no cookie in the request header for the first visit. If yours is, it means you have visited before, and the cookie value is always retained in the browser.
There is a cookielib package in python that can obtain cookies. The first visit is without cookies~~
The following is a test using firebug:
Since I have visited it before, there are cookies for this website on the browser, so clear them.
Visiting again at this time is the real first visit. If you visit again at this time, the packet capture is as follows:
The website will return set-cookie in the request for the first visit. The browser will store the set-cookie, and the cookie value will be brought with it when you visit it in the future. So~ There is no cookie in the request header for the first visit. If yours is, it means you have visited before, and the cookie value is always retained in the browser.
Use
requests.Session()