When I used patchright along with headless chromium on Ubuntu, I found that it hardly made any efforts to bypass detection...
The code I used is as follows:
from patchright.async_api import async_playwright
async with async_playwright() as p:
browser = await p.chromium.launch(
headless=True,
)
page = await browser.new_page()
await page.goto("https://bot.sannysoft.com/")
await page.wait_for_load_state()
await page.screenshot(path="screenshot.png")
The result:

In fact, just the "Headless" keyword in the User Agent is enough to make google.com trigger the BOT detection (and I easily bypassed it by simply replacing it), which makes it almost impossible to use in the scenario of running browser user agents in batches on a server without UI infrastructure.

Even if I configure it according to the best practice mentioned in the README, there is still one item that is red:
from patchright.async_api import async_playwright
async with async_playwright() as p:
browser = await p.chromium.launch_persistent_context(
headless=False,
channel="chrome",
user_data_dir="./user_data",
no_viewport=True,
proxy=PROXY,
)
...

In contrast, when simply using https://github.com/Mattwmaster58/playwright_stealth along with headless chromium, all results are green:
# pip install git+https://github.com/Mattwmaster58/playwright_stealth@rc4
from playwright.async_api import async_playwright
from playwright_stealth import Stealth
async with Stealth().use_async(async_playwright()) as p:
browser = await p.chromium.launch(
headless=True,
)
...

And there is no need to use xvfb run to start it.
I don't understand why patchright doesn't perform some simple replacements of the uv and other string attributes for headless chromium to bypass some of the most basic detections. This brings some inconvenience to out-of-the-box usage.
When I used patchright along with headless chromium on Ubuntu, I found that it hardly made any efforts to bypass detection...
The code I used is as follows:
The result:
In fact, just the "Headless" keyword in the
User Agentis enough to make google.com trigger the BOT detection (and I easily bypassed it by simply replacing it), which makes it almost impossible to use in the scenario of running browser user agents in batches on a server without UI infrastructure.Even if I configure it according to the best practice mentioned in the README, there is still one item that is red:
In contrast, when simply using https://github.com/Mattwmaster58/playwright_stealth along with headless chromium, all results are green:
And there is no need to use xvfb run to start it.
I don't understand why patchright doesn't perform some simple replacements of the uv and other string attributes for headless chromium to bypass some of the most basic detections. This brings some inconvenience to out-of-the-box usage.