我正在尝试将 cookie 从 webdriver 对象复制到请求,如下面的代码所示。我在脚本的最后一条语句中收到此错误消息。
TypeError:无法将字典更新序列元素#0 转换为序列
import requests
import cookielib
from selenium import webdriver
import urllib
driver = webdriver.Chrome()
driver.get("http://www.google.com/")
cj = cookielib.CookieJar()
#iterate the drive Cookies
for c in driver.get_cookies():
print "%s -> %s" % (c['name'], c['value'])
ck = cookielib.Cookie(name=c['name'], value=urllib.unquote(c['value']), domain=c['domain'], \
path=c['path'], \
secure=c['secure'], rest={'HttpOnly': c['http_only']}, \
version =0, port=None,port_specified=False, \
domain_specified=False,domain_initial_dot=False, \
path_specified=True, expires=None, discard=True, \
comment=None, comment_url=None, rfc2109=False)
print ck
cj.set_cookie(ck)
rsp = requests.get('http://www.cisco.com/', cookies=cj)
为什么我会收到此错误,我该如何解决?