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()
大家讲道理2017-04-18 10:21:55
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
高洛峰2017-04-18 10:21:55
First of all, pickle is not safe and it is unique to Python. If you interact with other languages, it cannot be operated