我正在尝试将python请求会话cookie添加到我的selenium webdriver中.
到目前为止我已经尝试过了
for c in self.s.cookies :
driver.add_cookie({'name': c.name, 'value': c.value, 'path': c.path, 'expiry': c.expires})
这段代码适用于PhantomJS,而不适用于Firefox和Chrome.
我的问题:
for cookie in s.cookies: # session cookies
# Setting domain to None automatically instructs most webdrivers to use the domain of the current window
# handle
cookie_dict = {'domain': None, 'name': cookie.name, 'value': cookie.value, 'secure': cookie.secure}
if cookie.expires:
cookie_dict['expiry'] = cookie.expires
if cookie.path_specified:
cookie_dict['path'] = cookie.path
driver.add_cookie(cookie_dict)
Run Code Online (Sandbox Code Playgroud)
检查这个是否有完整的解决方案https://github.com/cryzed/Selenium-Requests/blob/master/seleniumrequests/request.py
归档时间: |
|
查看次数: |
5788 次 |
最近记录: |