Skip to content

playwrightvspydoll

Apache-2.0 7 9 15,138
140.4 million (month) Feb 24 2021 1.65.2(2026-11-14 00:28:39 ago)
7,155 7 22 MIT
Jun 01 2024 86.5 thousand (month) 3.0.1(2026-11-08 11:38:44 ago)

playwright is a Python package that allows developers to automate web browsers for end-to-end testing, web scraping, and web performance analysis. It is built on top of WebKit, Mozilla's Gecko, and Microsoft's EdgeHTML, and it is designed to be fast, reliable, and easy to use.

playwright is similar to Selenium, but it provides a more modern and powerful API, with features such as automatic waiting for elements, automatic retries, and built-in support for browser contexts, which allow you to open multiple pages in a single browser instance.

Playwright also provides an asynchronous client which makes scaling playwright-powered web scrapers easier than alternatives (like Selenium)

Pydoll is a Python library for browser automation that uses the Chrome DevTools Protocol (CDP) directly, designed to be undetectable by anti-bot systems. Unlike Selenium-based tools, Pydoll does not use WebDriver and avoids the common detection vectors that anti-bot systems look for.

Key features include:

  • Native CDP communication Connects directly to Chrome/Chromium via CDP websocket without intermediary drivers, avoiding the automation flags and fingerprints that WebDriver-based tools leave behind.
  • Event-driven architecture Built around an async event system that can listen for and react to browser events like network requests, console messages, and DOM changes.
  • Network interception Can intercept, modify, and mock network requests and responses, useful for blocking unnecessary resources or modifying API responses during scraping.
  • Async-first design Fully asynchronous API built on Python's asyncio for efficient concurrent automation.
  • Clean API Provides a high-level, Pythonic API for common browser automation tasks while still allowing direct CDP command execution for advanced use cases.
  • Multi-browser support Can manage multiple browser instances and pages concurrently.

Pydoll fills a similar niche to nodriver and camoufox — browser automation with a focus on avoiding detection — but takes a different approach by providing more granular control over CDP communication and network interception.

Highlights


anti-detectcdpasync

Example Use


from playwright import sync_playwright

# Start Playwright
with sync_playwright() as playwright:
    # Launch a browser instance
    browser = playwright.chromium.launch()
    # Open a new context (tab)
    context = browser.new_context()
    # Create a new page in the context
    page = context.new_page()

    # Navigate to a website
    page.goto("https://www.example.com")

    # Find an element by its id
    element = page.get_by_id("example-id")

    # Interact with the element
    element.click()

    # Fill an input form
    page.get_by_name("example-name").fill("example text")

    # Find and click a button
    page.get_by_xpath("//button[text()='Search']").click()

    # Wait for the page to load
    page.wait_for_selector("#results")

    # Get the page title
    print(page.title)

    # Close the browser
    browser.close()
import asyncio
from pydoll.browser import Chrome
from pydoll.constants import By

async def main():
    async with Chrome() as browser:
        # Open a new page
        page = await browser.new_page()
        await page.go_to("https://example.com")

        # Find and interact with elements
        search_input = await page.find_element(By.CSS, "input[name='q']")
        await search_input.type_text("web scraping")

        submit_btn = await page.find_element(By.CSS, "button[type='submit']")
        await submit_btn.click()

        # Wait for results and extract content
        await page.wait_element(By.CSS, ".results")
        results = await page.find_elements(By.CSS, ".result-item")

        for result in results:
            title = await result.get_text()
            print(title)

        # Network interception example
        await page.enable_network_interception()
        # intercept and analyze API calls made by the page

asyncio.run(main())

Alternatives / Similar


Was this page helpful?