84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
import requests sess=requests.session() resp=sess.get('http://www.so.com') f=open('cookiefile','wb') pickle.dump(resp.cookies,f) #为什么很多代码都不是这样,而是使用cookielib的LWPCookieJar? f.close()
认证高级PHP讲师
How do you restore it, use load ?
After restoration, how do you operate cookies (add, delete, modify, check)
The cookie after you load is just a string. There are no more abstract operations, and you have to write your own functions to implement it
Cookie is an entity, so it is naturally suitable to use class to abstractly encapsulate it
It’s not that you can’t use pickle, it’s a question of convenience or inconvenience
It is a compromise choice after weighing the pros and cons of all aspects
First of all, pickle is not safe and it is unique to Python. If you interact with other languages, it cannot be operated
How do you restore it, use load ?
After restoration, how do you operate cookies (add, delete, modify, check)
The cookie after you load is just a string. There are no more abstract operations, and you have to write your own functions to implement it
Cookie is an entity, so it is naturally suitable to use class to abstractly encapsulate it
It’s not that you can’t use pickle, it’s a question of convenience or inconvenience
It is a compromise choice after weighing the pros and cons of all aspects
First of all, pickle is not safe and it is unique to Python. If you interact with other languages, it cannot be operated