Search
 
SCRIPT & CODE EXAMPLE
 

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'])
Comment

selenium get cookies python

# 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"))
Comment

python requests cookies to selenium

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})
Comment

PREVIOUS NEXT
Code Example
Python :: del all variables python 
Python :: how to uninstall python2.7 from ubuntu 18.04 
Python :: tensor vs numpy array 
Python :: numpy check if an array is all zero 
Python :: count characters in string python 
Python :: print dictionary of list 
Python :: python network programming 
Python :: how does urllib.parse.urlsplit work in python 
Python :: select rows from dataframe pandas 
Python :: python how to calculate how much time code takes 
Python :: maxsize in python 
Python :: plot a circle in python using equation of a circle 
Python :: how to get scrapy output file in csv 
Python :: how to add window background in pyqt5 
Python :: excel write in row 
Python :: python byte string 
Python :: random split train test in python 
Python :: how to get the ip address of laptop with python 
Python :: python obfuscator 
Python :: takes 1 positional argument but 2 were given python 
Python :: check if variable is of type decimal.Decimal python 
Python :: read file contents python 
Python :: how to have requirement file in python for libs 
Python :: re.compile example 
Python :: python num2words installation 
Python :: isinstance python 
Python :: python input integer only 
Python :: access django server from another machine 
Python :: python generator 
Python :: how to use function in python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =