【问题标题】:Disable image load in Chrome with Selenium in Python [duplicate]在Python中使用Selenium禁用Chrome中的图像加载[重复]
【发布时间】:2020-11-24 21:10:39
【问题描述】:

如何禁用 chrome 中的图像加载

browser.get("chrome://settings/content/images")
time.sleep(5)
images = browser.find_element_by_id('addSite')
images.click()
text = browser.find_element_by_css_selector("[id='input']")
text.send_keys("https://www.instagram.com/")
accept = browser.find_element_by_xpath("//button[text()='Añadir']")
accept.click() 

我试图进入 chrome 中的设置页面并单击被阻止的站点并添加 instagram,因此它会阻止 instagram 中的图像,但它无法在页面上找到按钮。 有人知道另一种方法吗? 我尝试使用扩展名,但它的 .crx 和 chrome 只喜欢 .crx3

【问题讨论】:

    标签: python image selenium google-chrome selenium-chromedriver


    【解决方案1】:
    option = webdriver.ChromeOptions()
    chrome_prefs = {}
    option.experimental_options["prefs"] = chrome_prefs
    chrome_prefs["profile.default_content_settings"] = {"images": 2}
    chrome_prefs["profile.managed_default_content_settings"] = {"images": 2}
    browser = webdriver.Chrome(chrome_options=option)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-02
      • 2015-09-22
      • 2021-06-11
      • 1970-01-01
      • 2010-10-25
      • 1970-01-01
      相关资源
      最近更新 更多