I am trying to generate HTML, for JS driven page using the spatie/browsershot
.
I am using this code:
$result = Browsershot::url('https://example.com')
->waitUntilNetworkIdle(true)
->setOption('userAgent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36')
->noSandbox()
->bodyHtml();
dump($result);
In the background this code generates the following command:
PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/html/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"https:\/\/example.com","action":"content","options":{"args":["--no-sandbox"],"viewport":{"width":800,"height":600},"waitUntil":"networkidle0","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/67.0.3396.99 Safari\/537.36"}}'
However, this doesn't seem to execute any of the JS, as I get the HTML without the JS generated DOM... any ideas what could be wrong?