首页 新闻 会员 周边 捐助

python 添加cookie报错Unable to set Cookie

0
悬赏园豆:50 [已关闭问题] 关闭于 2018-03-16 18:32

cookies = browser.get_cookies()
browser.close()
print(cookies)

dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap['phantomjs.page.settings.userAgent'] = ('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36')
web = webdriver.PhantomJS(executable_path='phantomjs.exe', desired_capabilities=dcap)
web.get('https://www.baidu.com')
web.delete_all_cookies()
for cookie in cookies:
for k in ('name', 'value', 'domain', 'path', 'expiry'):
if k not in list(cookie.keys()):
if k == 'expiry':
t = time.time()
cookie[k] = int(t)
web.add_cookie({k: cookie[k] for k in ('name', 'value', 'domain', 'path', 'expiry') if k in cookie})
web.get('https://www.baidu.com')
data = web.page_source

print(data)
随缘盛世的主页 随缘盛世 | 初学一级 | 园豆:130
提问于:2018-03-16 17:50
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册