from selenium import webdriver
import json
browser = webdriver.Chrome()
url = 'https://www.google.com/'
browser.get(url)
cookie = browser.get_cookies()
browser.quit()
with open('cookie', 'w') as j_out:
json.dump(cookie, j_out)
with open('cookie') as j:
saved_cookie = json.load(j)
#print(saved_cookie) # The whole cookie as a list with dictionaries
print(saved_cookie[0]['domain'])
print(saved_cookie[0]['httpOnly'])
# Here is a sample code from https://www.selenium.dev/documentation/webdriver/browser/cookies/
from selenium import webdriver
driver = webdriver.Chrome()
# Navigate to url
driver.get("http://www.example.com")
# Adds the cookie into current browser context
driver.add_cookie({"name": "foo", "value": "bar"})
# Get cookie details with named cookie 'foo'
print(driver.get_cookie("foo"))
driver.get("https://www.cartetitolari.mps.it/portaleTitolari/titolari.html")
for c in session.cookies :
driver.add_cookie({'name': c.name, 'value': c.value, 'path': c.path, 'expiry': c.expires})