问题
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