<legend id='PHt4d'><style id='PHt4d'><dir id='PHt4d'><q id='PHt4d'></q></dir></style></legend>

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

  1. <small id='PHt4d'></small><noframes id='PHt4d'>

      <tfoot id='PHt4d'></tfoot>

      在 chromedriver 中使用 python 绑定为 selenium 设置 c

      时间:2023-10-08
        <tbody id='fm7lz'></tbody>
        <legend id='fm7lz'><style id='fm7lz'><dir id='fm7lz'><q id='fm7lz'></q></dir></style></legend>

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

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

              • 本文介绍了在 chromedriver 中使用 python 绑定为 selenium 设置 chrome.prefs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我整天都在寻找这个,似乎目前没有可用的解决方案可从 python 的 chromedriver 实现中获得.

                I have been searching all day for this and it seems that there is no solution currently available from the chromedriver implementation for python.

                如何使用 webdriver.Chrome() 方法设置特定的 chrome.prefs(例如 profile.managed_default_content_settings.images = 2 等配置文件设置)?

                how do you set specific chrome.prefs (for example profile settings such as profile.managed_default_content_settings.images = 2) using the webdriver.Chrome() method?

                我已经通过 webdriver.ChromeOptions() 尝试过,但没有成功.在 Java 中,有适当的函数可以实现这一点.

                I already tried it through webdriver.ChromeOptions() without success. In Java there are appropriate functions available to achieve this.

                但是 Python 呢?这就是我目前正在做的事情......

                But Python? This is what I am doing currently...

                    options = webdriver.ChromeOptions()
                    options.add_argument('--allow-running-insecure-content')
                    options.add_argument('--disable-web-security')
                    options.add_argument('--disk-cache-dir=/var/www/cake2.2.4/app/tmp/cache/selenium-chrome-cache')
                    options.add_argument('--no-referrers')
                    options.add_argument('--window-size=1003,719')
                    options.add_argument('--proxy-server=localhost:8118')
                    options.add_argument("'chrome.prefs': {'profile.managed_default_content_settings.images': 2}")
                
                
                    self.selenium = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',chrome_options=options)
                

                推荐答案

                对于任何想在 chromedriver 中禁用图像的人,以下代码可能会对您有所帮助.

                For anyone who want to disable images in chromedriver, the following code might help you.

                from selenium.webdriver.chrome.options import Options
                chrome_options = Options()
                chrome_options.add_experimental_option( "prefs", {'profile.default_content_settings.images': 2})
                driver = webdriver.Chrome(chrome_options=chrome_options)
                

                这篇关于在 chromedriver 中使用 python 绑定为 selenium 设置 chrome.prefs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何修复硒“DevToolsActivePort 文件不存在"Pyt 下一篇:如何在 Selenium (Python) 中将打开的页面保存为 pd

                相关文章

                最新文章

                <legend id='ZrWMo'><style id='ZrWMo'><dir id='ZrWMo'><q id='ZrWMo'></q></dir></style></legend>
                <tfoot id='ZrWMo'></tfoot>

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

                  <bdo id='ZrWMo'></bdo><ul id='ZrWMo'></ul>

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