Enable Flash with Chromedriver in Python

让人想犯罪 __ 提交于 2019-12-18 07:14:52

问题


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.


回答1:


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)



回答2:


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)


来源:https://stackoverflow.com/questions/48468305/enable-flash-with-chromedriver-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!