Z
Z
Zimaell2019-08-07 12:37:28
PHP
Zimaell, 2019-08-07 12:37:28

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;

Now, as it is indicated in the instructions for those plugins
const puppeteer = require("puppeteer-extra")
puppeteer.use(require("puppeteer-extra-plugin-stealth")())

you need to connect them, but I just don’t know how to do it in PHP in my code, tell me who knows how to do it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-08-07
@Zimaell

Call the node command from php via exec(), and in it there are already actions with js with puppeter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question