<small id='es8cm'></small><noframes id='es8cm'>

    • <bdo id='es8cm'></bdo><ul id='es8cm'></ul>
  1. <i id='es8cm'><tr id='es8cm'><dt id='es8cm'><q id='es8cm'><span id='es8cm'><b id='es8cm'><form id='es8cm'><ins id='es8cm'></ins><ul id='es8cm'></ul><sub id='es8cm'></sub></form><legend id='es8cm'></legend><bdo id='es8cm'><pre id='es8cm'><center id='es8cm'></center></pre></bdo></b><th id='es8cm'></th></span></q></dt></tr></i><div id='es8cm'><tfoot id='es8cm'></tfoot><dl id='es8cm'><fieldset id='es8cm'></fieldset></dl></div>
    <legend id='es8cm'><style id='es8cm'><dir id='es8cm'><q id='es8cm'></q></dir></style></legend>

    1. <tfoot id='es8cm'></tfoot>

      如何修复“无效的参数:无效的‘到期’"在向 chromedriver 添加 cookie 时在 Seleniu

      How to fix quot;invalid argument: invalid #39;expiry#39;quot; in Selenium when adding cookies to a chromedriver?(如何修复“无效的参数:无效的‘到期’在向 chromedriver 添加 cookie 时在 Selenium 中?)

      • <small id='K7KSm'></small><noframes id='K7KSm'>

        <legend id='K7KSm'><style id='K7KSm'><dir id='K7KSm'><q id='K7KSm'></q></dir></style></legend>
        <tfoot id='K7KSm'></tfoot>
        <i id='K7KSm'><tr id='K7KSm'><dt id='K7KSm'><q id='K7KSm'><span id='K7KSm'><b id='K7KSm'><form id='K7KSm'><ins id='K7KSm'></ins><ul id='K7KSm'></ul><sub id='K7KSm'></sub></form><legend id='K7KSm'></legend><bdo id='K7KSm'><pre id='K7KSm'><center id='K7KSm'></center></pre></bdo></b><th id='K7KSm'></th></span></q></dt></tr></i><div id='K7KSm'><tfoot id='K7KSm'></tfoot><dl id='K7KSm'><fieldset id='K7KSm'></fieldset></dl></div>
            <tbody id='K7KSm'></tbody>
            <bdo id='K7KSm'></bdo><ul id='K7KSm'></ul>

                本文介绍了如何修复“无效的参数:无效的‘到期’"在向 chromedriver 添加 cookie 时在 Selenium 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试将 cookie 添加到浏览器,但出现以下错误:

                I'm trying to add cookies to a browser, but getting the following error:

                消息:无效参数:无效的到期"(会话信息:chrome=75.0.3770.90)

                Message: invalid argument: invalid 'expiry' (Session info: chrome=75.0.3770.90)

                此代码显示了我如何加载和添加 cookie.

                This code shows how I load and add cookies.

                for cookie in pickle.load(open(r'{0}{1}_cookie.pkl'.format(settings.COOKIES_PATH, self.tv_username), 'rb')):
                    self.browser.add_cookie(cookie)
                

                cookie 的值:

                {'__utmc': '226258911', '_sp_id.cf1a': '0b243b32-8dee-46d9-a243-bb4d2bfcb805.1560942815.1.1560942821.1560942815.5941cbc0-0500-4a17-8f6c-4ee3f133f67c', 'km_vs': '1', '__utmt': '1', '__utma': '226258911.510671571.1560942814.1560942814.1560942814.1', 'km_ai': 'm6caeIAUtEqx%2BIWda%2F7klZER%2F1Y%3D', 'kvcd': '1560942821112', '__utmb': '226258911.2.10.1560942814', 'km_lv': '1560942821', '__utmz': '226258911.1560942814.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)', 'etg': 'undefined', '_sp_ses.cf1a':'*'}
                

                它适用于以前版本的 chrome.任何帮助将不胜感激!

                It worked fine with previous version of chrome. Any help would be appreciated!

                推荐答案

                问题是您尝试添加的 cookie 格式与 selenium 预期的格式不同.

                The problem is that you are trying to add the cookies with a different format than the selenium expects.

                python selenium api 参考 说你必须用这样的字典插入 cookie

                The python selenium api reference says that you have to insert the cookies with a dict like that

                driver.add_cookie({'name' : 'foo', 'value' : 'bar'})
                

                因此您必须调整循环以使用键值格式

                So you have to adapt your loop to use a key,value format

                for key, value in pickle.load(open(r'{0}{1}_cookie.pkl'.format(settings.COOKIES_PATH, self.tv_username), 'rb')):
                    self.browser.add_cookie({'name' : key, 'value' : value})
                

                这篇关于如何修复“无效的参数:无效的‘到期’"在向 chromedriver 添加 cookie 时在 Selenium 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                Centering an object in Kivy(在 Kivy 中将对象居中)
                How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                      <tbody id='0DOiR'></tbody>

                      <legend id='0DOiR'><style id='0DOiR'><dir id='0DOiR'><q id='0DOiR'></q></dir></style></legend>

                      <small id='0DOiR'></small><noframes id='0DOiR'>

                        <bdo id='0DOiR'></bdo><ul id='0DOiR'></ul>
                        <tfoot id='0DOiR'></tfoot>
                          <i id='0DOiR'><tr id='0DOiR'><dt id='0DOiR'><q id='0DOiR'><span id='0DOiR'><b id='0DOiR'><form id='0DOiR'><ins id='0DOiR'></ins><ul id='0DOiR'></ul><sub id='0DOiR'></sub></form><legend id='0DOiR'></legend><bdo id='0DOiR'><pre id='0DOiR'><center id='0DOiR'></center></pre></bdo></b><th id='0DOiR'></th></span></q></dt></tr></i><div id='0DOiR'><tfoot id='0DOiR'></tfoot><dl id='0DOiR'><fieldset id='0DOiR'></fieldset></dl></div>