Take screenshots of web pages

Hi

I am trying to create a stream that goes to a web page and pulls out screenshots and then sends the image by chatbot via telegram.

About sending the telegram I managed to send, but the part of taking the screenshot of the page I can not evolve ..

Has anyone done something similar? e Can you share the solution?

I am testing with the streams below:

node-red-contrib-web-page-screenshot
node-red-contrib-webshot

What do you mean by 'goes to a web page'? Is the page to be displayed in the browser viewing node red or do you mean that the node-red server should fetch the web page and somehow create an image that looks like a screenshot of the page as if it were displayed in a browser?

Hello thanks for the answer

The flow is determined by command that the user gives via red bot via telegram.
Between them he goes to www.google.com and returns me a screenshot. This image I resubmit as an answer. via red bot.

Can you understand?
www.google.com is an example

To get a screenshot of a browser page, you will need a suitable tool or set of tools to capture and render the page to an image - you will need to look for that first. When you know how to do that, you can automate it from Node-RED.

I expected something like that, but it didn't work for me.

But thanks for spending your time answering me. thankful

Do the examples given with that node work for you?

Unfortunately the two options that have the same way did not work for me, I posted this to seek another option with friends here.

Since even the examples don't work then you might be best to post an issue on the node's github page.

Hello
I've done it .. Here I am looking for alternatives.
Thank you.

I do this by executing a robot framework command from the exec node. In robot framework (a framework for test automation) I use a selenium library and selenium driver to go to a page, log in and make a screenshot. This screenshot is then locally available to send. For me this is the most stable solution. I think there are maybe easier ones. I had the advantage that I was already familiar with robot framework.

3 Likes

Hi,

Depending on how much work you want to put into this and what type of web site you want to access / screen-shot... If you have requirements like a web site with login, navigate multiple pages etc. you will need to invest more effort. In that case I'd suggest 'wdio' nodes which let you completely automate any web site including tasks like screen-scraping.

It will need a end-point to talk to (e.g. 'selenium-standalone' is a good fit) but that is pretty easy to do. Runs in a shell session and all it does is listen for wdio commands and controls a browser. This is similar (but more powerful) than 'Robot Framework' proposed above. Again - depends on how often you will do these tasks and the complexity of the navigation sequence you need to do.

Cheers,
Paul

1 Like

Does anyone have a working solution for this? I am trying to take a screenshot not from the dashboard, but from another page. I want to use node-red-contrib-web-page-screenshot, and I have also installed Chromium-headless on my raspberry pi, when when I trigger a node I see the following in the node-red-log:

(node:491) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome! bootstrap_helper: /usr/lib/chromium-browser/nacl_helper: Cannot open ELF file! errno=2 [1:1:1213/105402.285765:ERROR:nacl_fork_delegate_linux.cc(315)] Bad NaCl helper startup ack (0 bytes) [4613:4613:1213/105402.293272:ERROR:browser_main_loop.cc(495)] Failed to put Xlib into threaded mode. [4613:4613:1213/105402.301780:ERROR:browser_main_loop.cc(272)] Gtk: cannot open display: TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md at onClose (/home/pi/.node-red/node_modules/puppeteer/lib/Launcher.js:348:14) at ChildProcess.helper.addEventListener (/home/pi/.node-red/node_modules/puppeteer/lib/Launcher.js:338:60) at ChildProcess.emit (events.js:203:15) at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) (node:491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

To be honest, I have no idea what that means. Did anyone of you manage to install chromium headless on a pi? If I just apt-get install it, I get the message that it is correctly installed.

Regards,
Csongor

Couple questions to start this off with:
What OS do you run on your pi?
Do you have a desktop environment installed, and if so, is $DISPLAY set correctly?
Do you have all dependencies installed, for example for Debian see https://github.com/puppeteer/puppeteer/issues/290#issuecomment-322838700

Did you see the note from the node's readme ( https://flows.nodered.org/node/node-red-contrib-web-page-screenshot )

Are you running a compatible chromium-browser?

See this issue thread on Puppeteer: https://github.com/puppeteer/puppeteer/issues/550
The ELF error shown suggests that the version of chromium-browser that you're running is incompatible with the architecture on your OS. For example running x86_64 on ARM.

I am running Raspbian GNU/Linux 8 (jessie). I am using my pi headless, nothing is connected to it. I have no installed the dependencies as well. I have also seen the comment on the node page about the executablePath. And I set it as described.
I am afraid this goes above my head a bit. I could be running the x86_64 version but building my arm version is too complicated to me.