AtuboDad / playwright_stealth

playwright stealth
MIT License
434 stars 53 forks source link

playwright stealth + persistent context #11

Open codeman5000 opened 2 years ago

codeman5000 commented 2 years ago

hello,

i would like my browser to be undetectable for anti bot systems and this works if i use a chromium browser with chrome channel in stealth mode. however i would like my cookies and user data to be saved to reuse for next session.

so i launch my chrome with

browsers[i] = await p.chromium.launch_persistent_context(c.folderpath_userdata + "\user" + str(i) + "\", channel="chrome", headless=False) page[i] = await browsers[i].new_page() await stealth_async(page[i])

however as soon as i use the persistent context i get a bot detecton webdriver on https://bot.sannysoft.com/

xx
bakibillah commented 7 months ago

i have faced same issue.

AndrewVeee commented 2 months ago

I think disabling AutomationControlled fixes this problem:

  browser = pw.chromium.launch_persistent_context(
      './chromium-data',
      args=["--disable-blink-features=AutomationControlled"],
  )

That seems to turn the "WebDriver" section green. Sadly, Cloudflare still manages to detect headless mode for me.

iloveitaly commented 1 month ago

@AndrewVeee were you able to get around headless detection on cloud flare?

AndrewVeee commented 1 month ago

I didn't have any luck getting around headless detection, but I gave up on it pretty early.

Instead, I used xvfb in Linux so the browser runs in a hidden X11. I would much prefer headless mode, but this works well enough for a light use case.

Hope that helps a little, I know it's not optimal.