Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python selenium get cookie and store cookie

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'])
Source by python-forum.io #
 
PREVIOUS NEXT
Tagged: #python #selenium #cookie #store #cookie
ADD COMMENT
Topic
Name
2+3 =