Z
Z
Zimaell2020-04-19 14:55:21
PHP
Zimaell, 2020-04-19 14:55:21

How to run puppeteer through proxy?

I'm trying to run puppeteer through a proxy

require('/var/www/html/vendor/autoload.php');
use Nesk\Puphpeteer\Puppeteer;
use Nesk\Rialto\Data\JsFunction;
use Nesk\Rialto\Exceptions\Node;
$proxy='.....................';
$puppeteer=new Puppeteer;
$options=array(
    'headless'=>false,
    'defaultViewport'=>array('width'=>1440,'height'=>900,'isMobile'=>false),
    'ignoreHTTPSErrors'=>true,
    'ignoreDefaultArgs'=>true,
    'args'=>array('--incognito',
    '--proxy-server='.$proxy.'',
    '--0',
    '--window-size=1440,900',
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--ignore-certifcate-errors',
    '--ignore-certifcate-errors-spki-list',
    '--shm-size=2gb')
  );
$options['browserWSEndpoint']='ws://localhost:3000/?ignoreDefaultArgs=true&headless=false&'.implode('&',$options['args']);
$browser=$puppeteer->connect($options);
$page=$browser->createIncognitoBrowserContext()->newPage();
$page->setUserAgent($user_agent);
$page->goto('https://.......');
$content=$page->content();

echo htmlentities($content);

$browser->close();

gives me an error
Fatal error: Uncaught Nesk\Rialto\Exceptions\Node\FatalException: net::ERR_TUNNEL_CONNECTION_FAILED at https://.....

without
'--proxy-server='.$proxy.'',

it works fine, but I need to be able to use it through a proxy, the proxy took a free one without a login and password, the proxy is definitely working at the time of checking ...

Tell me what I'm doing wrong and how to make it through a proxy?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question