Reiki 2020-04-16
常用操作cookie的方法如下:
from selenium import webdriver driver = webdriver.Chrome() driver.get(‘https://www.baidu.com‘) cookies = driver.get_cookies() # 获取所有cookie cookie = driver.get_cookie(name=‘aaa‘) # 获取key(name)为aaa的cookie driver.add_cookie({‘name‘:‘aaa‘, ‘value‘:‘bbb‘}) # 添加cookie driver.delete_cookie(name=‘aaa‘) # 删除名为aaa的cookie driver.delete_all_cookies() # 删除所有cookie