🎯 A customizable, anti-detection cloud browser powered by self-developed Chromium designed for web crawlers and AI Agents.👉Try Now
Back to Blog

How to Use Playwright Stealth for Scraping

Michael Lee
Michael Lee

Expert Network Defense Engineer

06-Nov-2025

infrastructure

  • Always up-to-date with latest anti-bot bypasses
  • Focus on your business logic, not infrastructure

Live Monitoring & Debugging

  • Live Session feature to watch your scraper in real-time
  • Session Replay for debugging failed requests
  • Comprehensive logs and analytics

How to Use Scrapeless Scraping Browser with Playwright

Integrating Scrapeless with your existing Playwright code is incredibly simple. With just a few steps, you can bypass any anti-bot measures and access the data you need.

Step 1: Sign Up and Get Your API Key

  1. Visit the Scrapeless Dashboard
  2. Sign up for a free account
  3. Navigate to the Settings tab
  4. Copy your API Key

Step 2: Replace Browser Launch with CDP Connection

Instead of launching a local browser, connect to Scrapeless's cloud browser using the CDP protocol:

Before (Standard Playwright):

python Copy
browser = await p.chromium.launch(headless=True)

After (Scrapeless Scraping Browser):

python Copy
from playwright.async_api import async_playwright

# Your Scrapeless API Key
API_KEY = "your_api_key_here"

# Build Scrapeless connection URL
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&session_ttl=180&proxy_country=ANY"

async with async_playwright() as p:
    # Connect to Scrapeless cloud browser
    browser = await p.chromium.connect_over_cdp(connection_url)
    page = await browser.newPage()
    # Your scraping logic here

Step 3: Test Against Protected Sites

Let's try scraping the same Cloudflare-protected page that blocked Playwright Stealth:

python Copy
from playwright.async_api import async_playwright
import asyncio

async def scraper():
    # Your Scrapeless API Key
    API_KEY = "your_api_key_here"
    
    # Scrapeless connection URL
    connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&session_ttl=180&proxy_country=ANY"
    
    async with async_playwright() as p:
        # Connect to Scrapeless cloud browser
        browser = await p.chromium.connect_over_cdp(connection_url)
        page = await browser.new_page()
        
        # Access Cloudflare-protected site
        await page.goto("https://www.scrapingcourse.com/antibot-challenge")
        
        # Extract content
        content = await page.content()
        print(content)
        
        # Take screenshot
        await page.screenshot(path="success_screenshot.png")
        
        await browser.close()

# run the scraper
if __name__ == "__main__":
    asyncio.run(scraper())

Result:

html Copy
<html lang="en">
<head>
    <title>Antibot Challenge - ScrapingCourse.com</title>
</head>
<body>
    <h2>
        You bypassed the Antibot challenge! :D
    </h2>
    <!-- Content successfully extracted -->
</body>
</html>

Congratulations! 🎉 You've successfully bypassed Cloudflare protection with Scrapeless Scraping Browser.


Advanced Configuration Options

Scrapeless Scraping Browser offers extensive configuration options for advanced use cases:

Custom Proxy Settings

python Copy
# Use a specific country proxy
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&proxy_country=US&session_ttl=300"

# Use your own proxy
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&proxy_url=http://your-proxy.com:8080"

Session Management

python Copy
# Create persistent session
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&session_name=my_session&session_ttl=600"

Enable Session Recording for Debugging

python Copy
# Record session for debugging
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&session_recording=true"

Custom Fingerprints

python Copy
# Use custom browser fingerprint
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&fingerprint=custom"

For more configuration options, visit the Scrapeless Documentation.


Comparison: Playwright Stealth vs Scrapeless Scraping Browser

Feature Playwright Stealth Scrapeless Scraping Browser
Setup Complexity Medium (requires configuration) Simple (one line change)
Anti-Bot Bypass Basic (fails on advanced systems) Advanced (99.9% success rate)
Cloudflare Bypass ❌ Fails ✅ Succeeds
CAPTCHA Solving ❌ Manual required ✅ Automatic
Maintenance ❌ Constant updates needed ✅ Zero maintenance
IP Rotation ❌ DIY required ✅ Built-in (70M+ IPs)
Global Proxies ❌ External service needed ✅ 195 countries covered
Performance Local (depends on hardware) ⚡ 10x faster (cloud-based)
Debugging Tools ❌ Limited ✅ Live Session + Replay
Scalability ❌ Limited by local resources ✅ Unlimited concurrent sessions
Cost Free (but high infrastructure cost) Pay-as-you-go (40-80% cheaper)
Support Community only ✅ Professional support

Real-World Use Cases

Scrapeless Scraping Browser excels in scenarios where Playwright Stealth fails:

1. E-commerce Price Monitoring

  • Scrape Amazon, Walmart, eBay without blocks
  • Track competitor prices in real-time
  • Handle dynamic pricing and inventory updates

2. Social Media Data Collection

  • Extract Instagram, LinkedIn, Twitter data
  • Bypass login walls and rate limits
  • Maintain persistent sessions

3. Travel & Hospitality Intelligence

  • Monitor flight prices, hotel rates
  • Access geo-restricted content
  • Handle JavaScript-heavy booking sites

4. Market Research & Lead Generation

  • Scrape B2B directories and databases
  • Extract contact information at scale
  • Comply with rate limits automatically

5. SEO & Competitor Analysis

  • Track keyword rankings globally
  • Analyze competitor strategies
  • Monitor SERP changes in real-time

Pricing & Cost Optimization

Scrapeless Scraping Browser offers flexible pricing:

  • Free Tier: Perfect for testing and small projects
  • Pay-As-You-Go: Only pay for what you use
  • Enterprise Plans: Custom solutions with SLA guarantees

Cost Comparison:

  • Running local Playwright: $200-500/month (server costs + maintenance)
  • Using Scrapeless: $50-150/month (40-80% cost reduction)

Plus, you eliminate:

  • ❌ Server maintenance costs
  • ❌ Proxy management costs
  • ❌ CAPTCHA solving service costs
  • ❌ Developer time spent on debugging

Best Practices

1. Respect Rate Limits

Even with Scrapeless's powerful capabilities, always respect target websites' rate limits:

python Copy
import asyncio

async def scrape_with_delay(urls):
    for url in urls:
        await page.goto(url)
        # Extract data
        await asyncio.sleep(2)  # 2-second delay between requests

2. Use Session Persistence

For websites requiring login:

python Copy
# Create persistent session
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&session_name=login_session&session_ttl=3600"

3. Enable Session Recording for Debugging

When developing:

python Copy
# Enable recording
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&session_recording=true"

Then view replays in the Scrapeless dashboard to debug failures.

4. Optimize Proxy Selection

Choose proxies based on your target:

python Copy
# US-only content
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&proxy_country=US"

# Global scraping
connection_url = f"wss://browser.scrapeless.com/browser?token={API_KEY}&proxy_country=ANY"

Conclusion

While Playwright is a popular headless browsing tool, its default properties make it easily detectable by target websites. Playwright Stealth helps mask some loopholes, but it falls short against advanced anti-bot systems like Cloudflare, DataDome, and AWS WAF.

To extract data reliably and at scale, we strongly recommend using an enterprise solution like Scrapeless Scraping Browser.

Why Scrapeless?

Zero Code Changes: One line replacement in your existing Playwright scripts
99.9% Success Rate: Bypass any anti-bot system including Cloudflare
Automatic CAPTCHA Solving: No manual intervention required
Global Proxy Network: 70M+ residential IPs across 195 countries
Zero Maintenance: Focus on your business logic, not infrastructure
Cost-Effective: 40-80% cheaper than DIY solutions
Professional Support: Get help when you need it

Try Scrapeless Scraping Browser for Free – No credit card required!


Frequently Asked Questions

1. Why Use Playwright Stealth?

Playwright Stealth helps mask Playwright's automation properties to avoid basic bot detection. It's a good starting point for simple scraping tasks but has limitations against advanced anti-bot systems.

2. Is Playwright Stealth Undetectable?

No. While Playwright Stealth can bypass basic bot detection, it fails against advanced anti-bot systems like Cloudflare, DataDome, and AWS WAF. For production use cases, we recommend Scrapeless Scraping Browser.

3. What Is the Best Way to Avoid Detection in Playwright?

The most reliable way is to use a professional cloud browser service like Scrapeless Scraping Browser, which offers:

  • Enterprise-grade anti-detection technology
  • Automatic CAPTCHA solving
  • Built-in proxy rotation
  • Zero maintenance
  • 99.9% uptime guarantee

4. Can I Use Scrapeless with My Existing Playwright Code?

Yes! Scrapeless requires minimal changes to your existing code. Simply replace the browser launch with a CDP connection to Scrapeless's cloud browser:

python Copy
# Before
browser = await p.chromium.launch(headless=True)

# After
browser = await p.chromium.connect_over_cdp(connection_url)

5. How Much Does Scrapeless Cost?

Scrapeless offers flexible pricing including a free tier for testing. Pay-as-you-go plans start from just a few dollars per month, making it 40-80% cheaper than running your own infrastructure. Check current pricing.

6. Does Scrapeless Support Other Languages Besides Python?

Yes! Scrapeless works with any language that supports Puppeteer, Playwright, or CDP protocol, including:

  • Python
  • Node.js
  • Java

7. Can Scrapeless Handle Login-Required Websites?

Absolutely! Scrapeless supports persistent sessions, allowing you to maintain login states across multiple requests. Use the session_name parameter to create persistent sessions.


Ready to take your web scraping to the next level?

Start Your Free Trial | View Documentation | Join Discord Community


Disclaimer: This guide is for educational purposes. Always respect websites' terms of service and robots.txt files. Web scraping should only be performed on publicly available data with proper authorization.

At Scrapeless, we only access publicly available data while strictly complying with applicable laws, regulations, and website privacy policies. The content in this blog is for demonstration purposes only and does not involve any illegal or infringing activities. We make no guarantees and disclaim all liability for the use of information from this blog or third-party links. Before engaging in any scraping activities, consult your legal advisor and review the target website's terms of service or obtain the necessary permissions.

Most Popular Articles

Catalogue