node-red-contrib-web-page-screenshot 0.2.2

A Node-RED node for taking screenshots of web pages.

npm install node-red-contrib-web-page-screenshot

A Node-RED node for taking screenshots of web pages, and this is my fav GYOUZA(dumpling).

ポキオ Node-RED スクリーンショット puppeteer

Install

cd ~/.node-red
npm install node-red-contrib-web-page-screenshot

Usage

  • If this node is triggered, this node will take a screenshot of the configured web page in setting screen.
  • This node takes a screenshot as PNG image, and encodes with base64.
  • The base64 string will be returned.

Settings

In setting menu, there are some items like below.

ポキオ Node-RED スクリーンショット puppeteer

Name (Optional)

You can set any name to the node. Blank is allowed.

Web Page URL (Optional)

URL which you want to take a screenshot. If blank, this node will take a screenshot of http://example.com .

executablePath (Optional)

You can specify chromium/chrome executable with the path. For those who use x86 arch, this can be blank, however, if you use this node on ARM arch (e.g. Raspberry Pi), you have to install headless-mode-available chromium-browser and set the path.

Fortunately, Raspbian OS (as of ver. April 2019) includes compatible chromium-browser, so just set /usr/bin/chromium-browser to this blank.

[UPDATED] Class Name (only in screenshot-class node)

For partial screenshots, you can specify a class name of element you want to take screenshots. If blank, a whole screenshot will be taken.

[UPDATED] ID Name (only in screenshot-id node)

For partial screenshots, you can specify a ID name of element you want to take screenshots. If blank, a whole screenshot will be taken.

Example

This flow provides a web page with a screenshot of a configured URL.

ポキオ Node-RED スクリーンショット puppeteer

[{"id":"67c61941.053d58","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2660a5a5.ba220a","type":"http in","z":"67c61941.053d58","name":"","url":"/test","method":"get","upload":false,"swaggerDoc":"","x":180,"y":140,"wires":[["2fe6f48.ec2f80c"]]},{"id":"2fe6f48.ec2f80c","type":"screenshot","z":"67c61941.053d58","name":"","url":"https://relativelayout.hatenablog.com/","x":300,"y":200,"wires":[["86463a3a.b78058"]]},{"id":"86463a3a.b78058","type":"template","z":"67c61941.053d58","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <body>\n        <img src=\"data:image/png;base64,{{payload}}\">\n    </body>\n</html>","output":"str","x":420,"y":260,"wires":[["769165e4.dc545c"]]},{"id":"769165e4.dc545c","type":"http response","z":"67c61941.053d58","name":"","statusCode":"","headers":{},"x":520,"y":320,"wires":[]}]

A point is, in HTML string of HTTP response, the base64 string is included like following.

<html><body><img src=\"data:image/png;base64,{{payload}}\"></body></html>

If you access the endpoint...

ポキオ Node-RED スクリーンショット puppeteer

You can see the screenshot on a web page.

Details and Issues

  • This node uses puppeteer for taking screenshots.

Node Info

Version: 0.2.2
Updated 3 months, 3 weeks ago
License: MIT
Rating: 5.0 1

Actions

Rate:

Downloads

21 in the last week

Nodes

  • screenshot
  • screenshot-class
  • screenshot-id

Keywords

  • node-red
  • web page
  • screenshot
  • puppeteer

Maintainers