rialto-php / puphpeteer

A Puppeteer bridge for PHP, supporting the entire API.
MIT License
1.34k stars 204 forks source link

Feat: support for puppeteer-extra plugins #149

Open xtrime-ru opened 3 years ago

xtrime-ru commented 3 years ago

Corresponding issue: https://github.com/rialto-php/puphpeteer/issues/67

Added new option to allow override puppeteer instance.

This is example usage of puppeteer-extra-plugin-stealth:

<?php
require "vendor/autoload.php";

use Nesk\Puphpeteer\Puppeteer;

$puppeteer = new Puppeteer([
    'js_extra' => /** @lang JavaScript */ "
        const puppeteer = require('puppeteer-extra');
        const StealthPlugin = require('puppeteer-extra-plugin-stealth');
        puppeteer.use(StealthPlugin());
        instruction.setDefaultResource(puppeteer);
    ",
]);
$browser = $puppeteer->launch();

$page = $browser->newPage();

$page->goto('https://bot.sannysoft.com');
$page->waitForTimeout(5000);
$page->screenshot(['path' => 'example2.png', 'fullPage'=> true]);

$browser->close();

Without plugin: example2

With plugin (code above): example

Dr10s commented 3 years ago

I'm waiting for this feature <3

btidude commented 3 years ago

I'm also waiting for this feature

overgapo commented 3 years ago

👍

jsandeo commented 2 years ago

👍

jfrancuz commented 2 years ago

@xtrime-ru - thanks a lot! @nesk, this feature is very much needed - please review the PR. Hopefully, it can be accepted!

xtrime-ru commented 2 years ago

@xtrime-ru - thanks a lot!

You welcome! While waiting nesk to aprove my PR you can use our fork with all new features:

TheWildHorse commented 2 years ago

Wow! Nice job dude! Would love for this to get this merged.