当我尝试使用Selenium的自动化python脚本打开一个flash页面时,我到达了下图所示的页面。我不能过关。

它是一个运行Ubuntu16.04的远程服务器,不能访问监视器或键盘/鼠标。
Python版本: 3.5.2
Selenium版本: 3.14.1
Geckodriver 0.26.0
遵循我的代码:
import pyvirtualdisplay
print ("pyvirtualdisplay Display Version: %s" % (pyvirtualdisplay.__version__))
from selenium import webdriver
print ("Selenium webdriver Version: %s" % (webdriver.__version__))
display = pyvirtualdisplay.Display(visible=0, size=(800, 600))
display.start()
profile = webdriver.FirefoxProfile()
profile.native_events_enabled = False
profile.set_preference("plugin.state.flash", 2)
profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so","true")
driver = webdriver.Firefox(profile)
driver.set_page_load_timeout(60)
url = 'https://www.ultrasounds.com/US.html'
driver.get(url)
driver.close()
driver.quit()
display.stop()
quit()下面是输出:
Python 3.5.2 (default, Apr 16 2020, 17:47:17)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvirtualdisplay
>>> print ("pyvirtualdisplay Display Version: %s" % (pyvirtualdisplay.__version__))
pyvirtualdisplay Display Version: 0.2.4
>>> from selenium import webdriver
>>> print ("Selenium webdriver Version: %s" % (webdriver.__version__))
Selenium webdriver Version: 3.14.1
>>>
>>> display = pyvirtualdisplay.Display(visible=0, size=(800, 600))
>>> display.start()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] oserror=None return_code=None stdout="None" stderr="None" timeout_happened=False>
>>>
>>> profile = webdriver.FirefoxProfile()
>>> profile.native_events_enabled = False
>>> profile.set_preference("plugin.state.flash", 2)
>>> profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so","true")
>>> driver = webdriver.Firefox(profile)
>>> driver.set_page_load_timeout(60)
>>> url = 'https://www.ultrasounds.com/US.html'
>>> driver.get(url)
>>>
>>>
>>> import pyautogui
>>> im1 = pyautogui.screenshot('flash_activation_page.jpg')
>>> driver.close()
>>> driver.quit()
>>> display.stop()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] oserror=None return_code=0 stdout="" stderr="" timeout_happened=False>
>>>发布于 2020-05-26 09:17:22
使用Firefox >= 69,您将无法做到这一点:
在Firefox69中删除了始终激活Adobe Flash插件的设置。详情请参见。
Flash Player不再总是处于激活状态
发布日期:2019年06月15日
分类:Plug-ins
发布:Firefox 69
描述
作为正在进行的Flash plug-in support deprecation的一部分,Firefox69已经从页面通知对话框中删除了“始终激活”选项,并从插件管理器中删除了“记住这个决定”选项。这意味着,从现在开始,Firefox将每次询问用户是否想在浏览器会话期间在网站上显示Flash内容,而用户将无法更改此行为。
在写这篇文章的时候,只有一半的火狐用户安装了Firefox Public Data Report的Flash Player,而且这个数字还在稳步下降。考虑到2020年将从Firefox和其他浏览器中移除对Flash的支持,如果您的站点仍然依赖于任何Flash内容(包括传统视频播放器),强烈建议您尽快制定迁移计划。
https://stackoverflow.com/questions/62013068
复制相似问题