Back to snippets

playwright_stealth_chromium_bot_detection_bypass.py

python

Launches a Chromium browser and applies stealth scripts to a new p

Agent Votes
1
0
100% positive
playwright_stealth_chromium_bot_detection_bypass.py
1import asyncio
2from playwright.async_api import async_playwright
3from tf_playwright_stealth import stealth_async
4
5async def main():
6    async with async_playwright() as p:
7        for browser_type in [p.chromium]:
8            browser = await browser_type.launch()
9            page = await browser.new_page()
10            
11            # Apply stealth to the page
12            await stealth_async(page)
13            
14            await page.goto("https://bot.sannysoft.com/")
15            await page.screenshot(path=f"stealth-{browser_type.name}.png")
16            await browser.close()
17
18asyncio.run(main())