1

I'm running a headless chrome to take screenshots of tweets via the oEmbed API.

Downloading the tweets and creating the HTML works fine, but the embedded JS does not run, which causes the tweets to be unstyled in the screenshot.

When I fetch the created HTML file and open it in my Firefox, the JS is loaded, executed and styles the tweet perfectly.

Is this a problem with headless chrome, twitter itself or something else?

My CLI command looks like this:

google-chrome -headless -screenshot=' + filename_image + ' ' + msg.filename + ' -force-device-scale-factor=2 -virtual-time-budget=20000 -window-size=516,3000 --disable-gpu

This is from the node-red script which prepares the CLI command which is then passed to the bash via an "exec"-node.

Edit #1: To make it clear: The screenshot works in general, but the result is unstyled, as no external script is loaded and executed.

I've also tried to disable ufw to check whether it's a problem with the firewall. It's not. The problem persists, even with disabled firewall.

Edit #2: I added the --disable-gpu flag to get rid of this error message, which was also written to the console. Sadly that didn't change anything about the end-result.

Edit #3: Back on this. Tried running the same exact command through a PHP script. Everything works fine, tweets are styled perfectly. Doesn't make this any less strange.

flomei
  • 860
  • 1
  • 11
  • 36
  • 1
    does it render properly if run from outside Node-RED? – hardillb Feb 05 '21 at 19:50
  • I just tried that. It renders the screenshot, but also without loading the external scripts. – flomei Feb 05 '21 at 20:03
  • 1
    Some searching suggests the screenshot arg may have issues with timing of the page load so maybe Google Puppeteer would work better as mentioned in https://stackoverflow.com/questions/61166503/chromium-chrome-running-headless-wait-for-page-load-when-using-screenshot – Drew MacInnis Feb 06 '21 at 13:40
  • I also have this problem. On local PC web page headless open OK. On VMware or docker, headless in chrome - web page open without JavaScript. Same py script in FireFox web page opened OK. Appear more 1 year ago, still i can't solve it. – Vik Kutenkov Sep 13 '21 at 13:41

0 Answers0