Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Headless node.js javascript browser with screenshot capability?

Are there any headless browsers for node.js that support dumping a rendered page out to a file? I know phantomjs supports rendering to a file, but it doesn't run on node.js. I know zombie.js is a node.js headless browser, but it doesn't support rendering to a file.

like image 477
ryeguy Avatar asked Aug 18 '11 13:08

ryeguy


People also ask

Is Jsdom a headless browser?

JSDOM is a JavaScript based headless browser that can be used to create a realistic testing environment. Since enzyme's mount API requires a DOM, JSDOM is required in order to use mount if you are not already in a browser environment (ie, a Node environment).

Is puppeteer a headless browser?

Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol.

Does puppeteer run JavaScript?

Puppeteer is a package that renders pages using a headless Chrome instance, executing the JavaScript within the page.


1 Answers

I doubt you will find anything that is going to work as well as phantomjs. I would just treat the rendering as an async backend process and execute phantom in a subprocess from your main node.js process and call it a day. Rendering a web page is HARD, and since phantom is based on WebKit, it can actually do it. I don't think there will ever be a node library that can render a web page to a graphic file that isn't built upon an existing browser rendering engine. But maybe one day phantomjs will integrate more seamlessly with node.

like image 54
Peter Lyons Avatar answered Sep 22 '22 19:09

Peter Lyons