Answers for "python save cookies"

0

python save cookies

import requests, pickle
session = requests.session()
# (Make some calls)

# Save the cookies to file:
with open('somefile', 'wb') as f:
    pickle.dump(session.cookies, f)
# __________________________________

# Get the cookies from file:
session = requests.session()  # or an existing session

with open('somefile', 'rb') as f:
    session.cookies.update(pickle.load(f))
Posted by: Guest on May-15-2021

Code answers related to "python save cookies"

Python Answers by Framework

Browse Popular Code Answers by Language