将请求(python)cookie保存到文件?
作者:互联网
#!/usr/bin/env python # -*- coding: utf-8 -*- import requests bot = requests.session() bot.get('http://google.com')
保持
import requests, pickle session = requests.session() # Make some calls with open('somefile', 'wb') as f: pickle.dump(session.cookies, f)
加载
session = requests.session() # or an existing session with open('somefile', 'rb') as f: session.cookies.update(pickle.load(f))
标签:cookies,请求,python,open,somefile,session,cookie,requests,pickle 来源: https://www.cnblogs.com/pythonClub/p/16389136.html