Skip to main content
 首页 » 编程设计

python之selenium 未启用 chrome 69 上的 Flash

2024年12月31日32linjiqin

在 google chrome 更新到版本 69 后,之前编写的用于在 python 上使用 selenium 启用 flash 的代码无法正常工作。如果有人找到了它的解决方案,请帮助我和社区

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": "URL" 
} 
options.add_experimental_option("prefs",prefs) 
 
browser = webdriver.Chrome(options=options) 

请您参考如下方法:

将此参数添加到 chrome_options。

chrome_options.add_argument("--disable-features=EnableEphemeralFlashPermission") 

在我的代码中:

from selenium import webdriver 
chrome_options = webdriver.ChromeOptions() 
chrome_options.add_argument("--disable-features=EnableEphemeralFlashPermission") 
 
chrome_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": "BEST URL EVER"} 
 
chrome_options.add_experimental_option("prefs",chrome_prefs) 
 
driver = webdriver.Chrome(chrome_options=chrome_options, service_log_path='NUL')