Python:如何在Firefox中自动“允许” Flash Player内容?

我需要在Python中以自动方式允许flash内容。我尝试在Python中使用Selenium,但是无法管理。问题是浏览器停止支持始终允许flash内容的设置。此外,例如,“不允许”按钮不能通过Selenium访问,因为它不是网站的一部分,也不是Firefox中的设置。有人知道潜在的解决方法吗?

这是我需要以某种方式访问​​的Firefox消息的图像:

Python:如何在Firefox中自动“允许” Flash Player内容?

timberjack 回答:Python:如何在Firefox中自动“允许” Flash Player内容?

  

“ ...例如,Allow按钮无法通过Selenium访问,因为它不是网站的一部分,也不是Firefox中的设置。有人知道潜在的解决方法吗?”

我不知道您的操作系统,但是如果这是我的问题...

  • 尝试查找“按键”模块,以将A按键发送到Firefox(即Allow快捷方式)。

  • 尝试在Allow按钮的坐标处单击鼠标。

一个不错的选择是pyautogui。通过此类模块(单击器或压片器)启用Flash后,您就可以在启用的Flash中进行Selenium的任何操作。

,

要通过Python使用What is Selenium and what is WebDriver?以自动化的方式允许 flash 内容,您需要使用FirefoxProfile()set_preference()方法的实例进行配置:>

  • dom.ipc.plugins.enabled.libflashplayer.so true
  • plugin.state.flash 2

代码块:

from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so","true")
profile.set_preference("plugin.state.flash",2)
driver = webdriver.Firefox(firefox_profile=profile,executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
本文链接:https://www.f2er.com/2994392.html

大家都在问