You need to enable JavaScript to run this app. 如何用Python Selenium的ChromeOptions默认启用Flash及内置插件?
优惠活动
大模型
产品
解决方案
定价
更多

如何用Python Selenium的ChromeOptions默认启用Flash及内置插件?

Enable Flash & All Built-in Plugins in Chrome for Web Automation (Python)

Hey there, I’ve got you covered for setting up Chrome to auto-enable Flash and all built-in plugins—no manual clicks needed, just like your Firefox setup. Here’s the practical Python solution using Selenium:

First, a quick heads-up: Modern Chrome versions (87 and above) have officially dropped Flash support. If Flash is critical for your automation, you’ll need to use Chrome version 86 or earlier (along with a matching ChromeDriver) that still includes the Flash plugin. With that out of the way, let’s jump into the code:

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

# Initialize ChromeOptions to tweak browser settings
chrome_options = Options()

# Define preference settings to auto-enable plugins and Flash
prefs = {
    # Enable all built-in plugins by default
    "profile.default_content_setting_values.plugins": 1,
    # Allow Flash content to run automatically without prompts
    "profile.default_content_setting_values.flash": 1,
    # Explicitly enable the Shockwave Flash plugin
    "plugins.plugins_enabled": ["Shockwave Flash"],
    # Optional: Enable external PDF viewer (adjust based on your specific plugin needs)
    "plugins.always_open_pdf_externally": True
}

# Attach the preferences to ChromeOptions
chrome_options.add_experimental_option("prefs", prefs)

# Add command-line flags to enforce plugin functionality
chrome_options.add_argument("--enable-plugins")
chrome_options.add_argument("--allow-outdated-plugins")  # Optional: Use if working with legacy plugin versions

# Launch Chrome with the configured settings
driver = webdriver.Chrome(options=chrome_options)

# Test by navigating to your target site with plugin/Flash content
driver.get("https://your-target-website.com")

Quick Explanations:

  • Flash Compatibility: Don’t forget the version note—newer Chrome builds won’t recognize Flash settings at all, so stick to v86 or earlier if Flash is non-negotiable.
  • Plugin Defaults: Setting profile.default_content_setting_values.plugins to 1 ensures every built-in plugin starts enabled, no manual toggling required.
  • Command-Line Flags: --enable-plugins makes sure Chrome’s plugin system is active, while --allow-outdated-plugins helps bypass blocks for older plugin versions that Chrome might flag.

This setup mirrors your Firefox profile configuration, letting you run automated sessions without dealing with any plugin permission pop-ups.

内容的提问来源于stack exchange,提问作者Dhiraj Jha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:52:47