selenium的cookie操作:
from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver=webdriver.Chrome() #配置参数 driver.get("https://www.youdao.com") #driver.find_element_by_id("kw").send_keys("python") #找到百度的kw搜索输入框内,输入hello #driver.find_element_by_id("kw").submit() # 提交 driver.add_cookie({'name' : 'foo', 'value' : 'bar'}) #增加cookie print(driver.get_cookies()) #抓取cookie print(driver.get_cookie("foo")) #抓取特定的cookie for line in driver.get_cookies(): print(line) time.sleep(5) driver.quit() #关闭全部