我正在编写脚本并希望能够为任何 HTML5 流或视频设置自动播放。如果更好,我想暂时从我所在的网站上阻止或删除它。我也会提供检查过的元素。
如果没有人知道以上内容,有什么办法可以阻止某个视频 ID 或类
<video id="still_video_object_html5_api" class="vjs-tech"
这些也是HTML5直播不变的脚本
webkit-playsinline="" playsinline="" autoplay="" tabindex="-1"
type="application/x-mpegURL"></video>
我正在使用:Windows 10 上的 Python、Selenium Webdriver 和 Chrome
最佳答案
使用 Chrome 67 和 C# 版本的 ChromeDriver 进行测试,这里是允许我自动播放 YouTube 视频的代码(而自 Chrome 66 以来的默认行为是禁用自动播放):
var options = new ChromeOptions();
options.AddArgument("--autoplay-policy=no-user-gesture-required");
IWebDriver browserDriver = new ChromeDriver(AppContext.BaseDirectory, options);
Python API 当然有等同于 AddArgument(string)
方法。
关于python - 如何使用 Selenium 和 Python 阻止或设置 HTML5 视频自动播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49367450/