Answers for "driver save cookies python"

3

python selenium save cookies

# read cookies

import pickle
import selenium.webdriver 

driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
    driver.add_cookie(cookie)
Posted by: Guest on August-25-2020
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 "driver save cookies python"

Python Answers by Framework

Browse Popular Code Answers by Language