Skip to content
Browserbase
    • Primitives
      • BrowsersCloud browsers for your agent to use the web
      • AgentsScale fully managed browser agents with simple prompts
      • SearchFind relevant websites from a single query
      • FetchRetrieve web data as agent-ready HTML, JSON, or markdown
      • RuntimeScalable, sandboxed environments for agent deployments
      • IdentityAuthenticate your agent to navigate the web like a human
      • ModelsUse any model with a single API key
      • ObservabilityUnified debugging your agent across replays, logs, and prompts
    • Open Source
      • Browse CLIGive your agent browsing skills with a single command
      • StagehandThe most popular AI browser automation framework
    • Use Cases
      • Browser Agents
      • Automated Testing
      • Workflow Automation
      • Web Data Extraction
      All use cases
    • Industries
      • AI & Agent Platforms
      • Healthcare
      • Fintech
      • GTM
      • Legal
    • Resources
      • Blog
      • Customers
      • Enterprise
      • Templates
  • Pricing
  • Docs
  • Log in
Log in
Sign up
Get a demo

Smart fetch scraper with browser fallback

Scrape webpages using the fastest method available: Fetch API first, full browser session as fallback for JS-rendered pages.

Smart fetch scraper with browser fallback demo

Works with

TypeScriptTypeScriptPythonPythonStagehandStagehand

Built by

Browserbase

Support

support@browserbase.com

Resources

Browserbase docsStagehand websiteStagehand docs
Copy prompt to run with your AI agent
npx create-browser-app --template smart-fetch-scraper
uvx create-browser-app --template smart-fetch-scraper

Send this template to your email, or view it on your desktop for the source code.

Get started with the Smart Fetch Scraper

Scrape web pages using the fastest and most cost-effective method available. The Browserbase Fetch API handles most pages instantly, retrieving content in milliseconds without spinning up a browser session or using AI credits. For the rare cases where JavaScript rendering is required, the template gracefully falls back to a full Stagehand browser session with AI-powered `extract()`. Perfect for cost-optimized scraping pipelines, speed-sensitive workflows, and hybrid data extraction scenarios.

Steps

  1. Send a POST request to the Browserbase Fetch API (`/v1/fetch`) with the target URL
  2. Check response content length and text density to determine if the page is server-rendered
  3. If content is sufficient, parse the HTML directly for fast, zero-cost extraction
  4. If content is insufficient (JS-rendered pages), fall back to a Stagehand browser session
  5. Use Stagehand's AI-powered extract() with Zod schemas to pull structured data from complex pages

Most Popular Templates

Quickstart: Playwright

Connect to a cloud browser via Playwright and Browserbase, navigate a real website, interact with UI elements, and extract page content.

Quickstart: Playwright

Find broken links on websites

Crawl your website to find broken links and validate page content automatically

Find broken links on websites

Extract & download images

Give it a URL, get back every image on the page. Handles product photos, hero images, thumbnails, whatever the page has.

Extract & download images
Browserbase

Primitives

  • Browsers
  • Web APIs
  • Runtime
  • Identity
  • Model Gateway
  • Observability
  • Stagehand
  • MCP

Industries

  • AI
  • Healthcare
  • GTM
  • Tax
  • Legal

Developers

  • Docs
  • Templates
  • APIs & SDKs
  • Changelog
  • Status
  • Github

Company

  • Careers
  • Customers
  • Partner with Us
  • Trust & Security

Community

TwitterLinkedinYoutube
  • Privacy Policy
  • Terms of Service

Community

TwitterLinkedinYoutube
  • Privacy Policy
  • Terms of Service