【问题标题】:Headless browser that supports HTML 5 video?支持 HTML 5 视频的无头浏览器?
【发布时间】:2015-11-10 04:02:40
【问题描述】:

我需要自动截取 HTML 5 视频播放器页面及其缩略图,但在查看了一些更流行的无头浏览器(如 PhantomJS)后,它们不支持 HTML 5 视频。

>phantomjs examples\features.js
Detected features (using Modernizr 2.0.6):

Supported:
  touch
  generatedcontent
  fontface
  flexbox
  canvas
  canvastext
  postmessage
  websqldatabase
  hashchange
  history
  draganddrop
  websockets
  rgba
  hsla
  multiplebgs
  backgroundsize
  borderimage
  borderradius
  boxshadow
  textshadow
  opacity
  cssanimations
  csscolumns
  cssgradients
  cssreflections
  csstransforms
  csstransitions
  localstorage
  sessionstorage
  webworkers
  applicationcache
  svg
  inlinesvg
  smil
  svgclippaths

Not supported:
  csstransforms3d
  webgl
  geolocation
  indexeddb
  video
  audio

注意上面不支持 HTML 5 视频,什么轻量级无头浏览器DOES 支持 HTML 5 视频?

【问题讨论】:

标签: html video headless-browser


【解决方案1】:

有一个解决方案但它不是轻量级的。(虽然速度很快)现在您可以使用无头选项运行 Firefox。这里有一些代码如何用 Selenium 来做

options = new FirefoxOptions();
options.addArguments("--headless"); // This will make Firefox to run in headless mode.
System.setProperty("webdriver.gecko.driver", "lib/firefox/geckodriver.exe");
        FirefoxProfile profile = new FirefoxProfile();
        FirefoxBinary binary = new FirefoxBinary(new File("lib/firefox/firefox.exe"));
        options.setBinary(binary);
        options.setProfile(profile);
        driver = new FirefoxDriver(options);

您可以构建 PanthomJS 以支持 HTML5。关注这个,https://github.com/ariya/phantomjs/issues/10839#issuecomment-331457673

【讨论】:

  • 编译phanotmjs时未能添加video支持
【解决方案2】:

基于the documentationSlimerJS可以播放HTML5视频和音频(并提供截图):

由于 SlimerJS 在 Firefox 之上执行,它支持最近在 Firefox 中实现的所有 HTML5 标准,包括音频、视频、WebGL 等。

SlimerJS 中的网页渲染与 Firefox 中的渲染完全相同。

您可以继续caniuse.com查看 Firefox 支持的 HTML5 功能列表,您可以在 SlimerJS 加载的网页中使用。

据说也支持 Flash,但屏幕截图中没有 Flash 内容:

如果安装了 Flash 插件,SlimerJS 就能够加载 Flash 内容(尽管在截屏时看不到插件的渲染)。

【讨论】:

  • 来自文档:it is not (yet) natively headless. However, it can be headless with the use of xvfb under Linux (but not on MacOS).
猜你喜欢
  • 2020-10-02
  • 1970-01-01
  • 1970-01-01
  • 2015-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多