berstend / puppeteer-extra

💯 Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.23k stars 732 forks source link

[Feature] Support playwright launch server #762

Open zhahaoyu opened 1 year ago

zhahaoyu commented 1 year ago

Feature request

I am trying to drive playwright in Java. Unfortunately, the nice extra plugins are not supported in Java, so I tried to start a playwright browser server with chromium.launchServer using the patched chromium in javascript and use another playwright instance in Java to connect to it through wsEndpoint.

I would love to have extra plugins, specifically the stealth plugin, work in this case.

zhahaoyu commented 1 year ago

This is the code I use

import StealthPlugin from 'puppeteer-extra-plugin-stealth'
import {chromium} from 'playwright-extra'
import {chromium as chromiumRegular} from 'playwright'

chromium.use(StealthPlugin())

export const launchPlaywrightBrowser = async () => {
  const browser = await chromium.launchServer({
    headless: false
  })

  const b2 = await chromiumRegular.connect(browser.wsEndpoint())
  const page = await b2.newPage()
  await page.goto("https://bot.sannysoft.com")
}

launchPlaywrightBrowser()