一、chrome的解决方式
from selenium import webdriver
chromeOpitons = Options()
prefs= {
#"profile.managed_default_content_settings.images":1,
#"profile.content_settings.plugin_whitelist.adobe-flash-player":1,
"profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player":1,
}
chromeOpitons.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(chrome_options=chromeOpitons)
二、FireFox的实现方式
# 下面代码的作用:以默认配置的方式启动火狐浏览器,同时允许使用flash
p = r"C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles\ff920jv6.default"
profile = webdriver.FirefoxProfile(p)
profile.set_preference("plugin.state.flash", 2)
driver = webdriver.Firefox(profile)