我正在尝试从cookie列表中打印特定的cookie值。我尝试了以下方法,但没有成功:
cookies_list = driver.get_cookies()
for name in cookies_list:
print name['cookiename']
我该怎么办?
谢谢
答案 0 :(得分:0)
您可以使用此:
from selenium import webdriver
cookies_list = driver.get_cookies()
cookies_dict = {} # create dictionary
for cookie in cookies_list:
cookies_dict[cookie['name']] = cookie['value'] # populate it
print(cookies_dict)