Skip to content

nodrivervsstagehand

AGPL-3.0 28 2 4,969
370.2 thousand (month) Jan 15 2024 0.50.99(2026-10-26 13:47:46 ago)
26,174 15 478 MIT
Oct 29 2024 11.2 million (month) 4.5.0(2026-11-27 21:43:59 ago)

nodriver is a Python library for browser automation that communicates directly with the browser via the Chrome DevTools Protocol (CDP), without relying on Selenium or chromedriver. It is the successor to undetected-chromedriver, created by the same author, and is designed from the ground up to be undetectable by anti-bot systems.

Key advantages over traditional browser automation:

  • No chromedriver dependency Communicates directly with Chrome/Chromium via CDP websocket, eliminating the most common detection vector (chromedriver fingerprint).
  • Undetectable by default Does not set the navigator.webdriver flag, does not inject automation-related JavaScript, and avoids CDP detection patterns that anti-bot systems look for.
  • Fast and lightweight Without the Selenium/WebDriver protocol overhead, nodriver is significantly faster at launching browsers and executing commands.
  • Async-first Built entirely on Python's asyncio, enabling efficient concurrent browser automation.
  • Simple API Clean, Pythonic API that is easier to use than raw CDP or Selenium.

nodriver is particularly useful for scraping websites protected by advanced anti-bot systems like Cloudflare, DataDome, or PerimeterX, where standard Selenium or Playwright setups get detected and blocked.

Stagehand is an AI-powered browser automation framework for JavaScript and TypeScript, built by Browserbase. It provides a simple API for controlling browsers using natural language instructions, powered by large language models.

Stagehand offers three core primitives:

  • act() Performs actions on the page described in natural language. For example, page.act("click the login button") will find and click the appropriate element.
  • extract() Extracts structured data from the page based on a natural language description and an optional schema definition.
  • observe() Analyzes the current page state and returns actionable elements and their descriptions, useful for understanding what actions are available on a page.

Key features include:

  • TypeScript-first Built with full TypeScript support and type-safe extraction using Zod schemas.
  • Multiple LLM providers Works with OpenAI, Anthropic, and other LLM providers for powering the AI.
  • Vision and DOM analysis Combines visual screenshot analysis with DOM inspection for robust element identification.
  • Playwright integration Uses Playwright as the browser automation backend, giving access to the full Playwright API alongside AI-powered actions.
  • Browserbase cloud Optionally integrates with Browserbase cloud for managed browser infrastructure.

Stagehand is particularly suited for automating complex web workflows where traditional selectors would be fragile, such as interacting with frequently changing UIs or scraping sites with dynamic layouts.

Highlights


anti-detectcdpasyncfast
ai-powerednatural-languagetypescript

Example Use


import nodriver as uc
import asyncio

async def main():
    # Launch browser - undetected by default
    browser = await uc.start()

    # Open a new tab and navigate
    tab = await browser.get("https://example.com")

    # Wait for an element and interact with it
    search_box = await tab.find("input[name='q']")
    await search_box.send_keys("web scraping")

    # Click a button
    button = await tab.find("button[type='submit']")
    await button.click()

    # Wait for navigation and extract content
    await tab.wait_for("div.results")
    results = await tab.query_selector_all("div.result")

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

    # Take a screenshot
    await tab.save_screenshot("results.png")

    browser.stop()

asyncio.run(main())
import { Stagehand } from '@browserbasehq/stagehand';
import { z } from 'zod';

const stagehand = new Stagehand({
    env: 'LOCAL',  // or 'BROWSERBASE' for cloud browsers
    modelName: 'gpt-4o',
});

await stagehand.init();
const page = stagehand.page;

// Navigate to a page
await page.goto('https://news.ycombinator.com');

// Use natural language to interact
await page.act('click on the "new" link in the navigation');

// Extract structured data with a schema
const stories = await page.extract({
    instruction: 'Extract the top 5 story titles and their point counts',
    schema: z.object({
        stories: z.array(z.object({
            title: z.string(),
            points: z.number(),
        })),
    }),
});
console.log(stories);

// Observe available actions on the page
const actions = await page.observe('What actions can I take on this page?');
console.log(actions);

await stagehand.close();

Alternatives / Similar


Was this page helpful?