selenium - webdriver 操作cookie
常用操作cookie的方法如下:
- get_cookie(name=‘aaa‘) 获取key(name)为aaa的cookie
- get_cookies() 获取所有cookie
- add_cookie(dict) 添加cookie
- delete_cookie(name=‘aaa‘) 删除cookie
- delete_all_cookies() 删除所有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
相关推荐
songerxing 2020-06-11
Luu 2020-06-08
houmenghu 2020-11-17
kentrl 2020-11-10
逍遥友 2020-10-26
jincheng 2020-09-01
Blueberry 2020-08-15
xclxcl 2020-08-03
zmzmmf 2020-08-03
阳光之吻 2020-08-03
PkJY 2020-07-08
hzyuhz 2020-07-04
89407707 2020-06-27
服务器端攻城师 2020-06-26
阳光岛主 2020-06-25
笨重的蜗牛 2020-06-20
xuanwenchao 2020-06-14
Lophole 2020-06-13