Enable Flash with Chromedriver in Python

2019-01-27 11:14发布

Trying to enable Adobe Flash Player in chromedriver using python. I've gone through a number of attempts including:

prefs = {'plugins.plugins_enabled': 'Adobe Flash Player'}

prefs = {'plugins.plugins_list' : [{'enabled':True,'name':'Adobe Flash 
Player'}]}

prefs = {
    'profile.default_content_setting_values.plugins': 1,
    'profile.content_settings.plugin_whitelist.adobe-flash-player': 1
}

along with a few other variations that I found from the top google results regarding this issue.

2条回答
Luminary・发光体
2楼-- · 2019-01-27 11:55

Ended up solving this with the following code:

prefs = {
    "profile.default_content_setting_values.plugins": 1,
    "profile.content_settings.plugin_whitelist.adobe-flash-player": 1,
    "profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-
     player": 1,
    "PluginsAllowedForUrls": "https://url.com"
}

options.add_experimental_option("prefs",prefs)
查看更多
混吃等死
3楼-- · 2019-01-27 11:58

Below is the complete solution starting from import.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
prefs = {
    "profile.default_content_setting_values.plugins": 1,
    "profile.content_settings.plugin_whitelist.adobe-flash-player": 1,
    "profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player": 1,
    "PluginsAllowedForUrls": "ENTER THE URL HERE"
}

options.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(options=options)
查看更多
登录 后发表回答