Answer the question
In order to leave comments, you need to log in
How to include nodejs library in php?
I am using Nesk\Puphpeteer, I needed to connect the puppeteer-extra and puppeteer-extra-plugin-stealth module, I installed them as indicated.
The location of the files is Nesk\Puphpeteer is in /var/www/html/vendor/ and those modules are in /var/www/html/node_modules/
Now I need to connect and use these modules in my script, at the moment my script is as follows
require('/var/www/html/vendor/autoload.php');
use Nesk\Puphpeteer\Puppeteer;
use Nesk\Rialto\Data\JsFunction;
use Nesk\Puphpeteer\Resources\ElementHandle;
$browser=$puppeteer->launch(['args'=>['--no-sandbox'],'headless' => true]);
$html_page=$browser->newPage();
$html_page->setUserAgent('Opera/9.80 (Windows NT 6.2; WOW64) Presto/2.12.388 Version/12.17');
$html_page=$browser->newPage();
$html_page->goto('https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html',['waitUntil'=>'networkidle2']);
$content=$html_page->evaluate(JsFunction::createWithBody('return document.documentElement.outerHTML'));
$browser->close();
echo $content;
const puppeteer = require("puppeteer-extra")
puppeteer.use(require("puppeteer-extra-plugin-stealth")())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question