Disabling PDF Viewer plugin in chromedriver

前端 未结 3 1517
隐瞒了意图╮
隐瞒了意图╮ 2020-12-20 03:08

I\'m trying to batch-download a lot of files within the BlackBoard environment (used a lot on universities/schools around the world). I am able to retrieve the links where t

相关标签:
3条回答
  • 2020-12-20 03:45

    Ari's answer was almost working properly. I only needed to encapsulate the plugin's name into a list:

    chromeOptions = webdriver.ChromeOptions()
    prefs = {"plugins.plugins_disabled" : ["Chrome PDF Viewer"]} # Here should be a list
    chromeOptions.add_experimental_option("prefs",prefs)
    chromedriver = "path/to/chromedriver.exe"
    driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)
    

    The downloading now works just fine!

    0 讨论(0)
  • 2020-12-20 03:45

    Can you set the plugin to be disable as a preference?

    chromeOptions = webdriver.ChromeOptions()
    prefs = {"plugins.plugins_disabled" : "Chrome PDF Viewer"}
    chromeOptions.add_experimental_option("prefs",prefs)
    chromedriver = "path/to/chromedriver.exe"
    driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)
    

    See "setting Chrome preferences w/ Selenium Webdriver in Python" and "How to disable Chrome Plugins in Selenium WebDriver using Java".

    0 讨论(0)
  • 2020-12-20 03:50

    Chrome 57 change the setting... use this to disable Chrome PDF viewer:

    //To disable PDF viewer plugins with Chrome 57
    chromePrefs.put("plugins.always_open_pdf_externally", true);
    
    0 讨论(0)
提交回复
热议问题