Python selenium don't autoplay videos

我与影子孤独终老i 提交于 2021-01-27 16:42:00

问题


I am using the Selenium webdriver in Python and I'd like the browser to not load images or autoplay videos to save time and resources. The problem is that videos do still get played without clicking on them.

Here are my settings for the webbrowser:

from selenium import webdriver

firefox_profile = webdriver.FirefoxProfile()

# don't load images
firefox_profile.set_preference('permissions.default.image', 2)
firefox_profile.set_preference('extensions.contentblocker.enabled', True)
firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', False)

# no video autoplay
firefox_profile.set_preference('media.autoplay.default', 1)
firefox_profile.set_preference('media.autoplay.allow-muted', False)
driver = webdriver.Firefox(firefox_profile=firefox_profile)

How can I stop the browser from autoplaying videos?

来源:https://stackoverflow.com/questions/61035556/python-selenium-dont-autoplay-videos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!