Skip to main content
Extract data from websites using cloud browsers that handle JavaScript rendering, bot protection, and dynamic content. Browserbase gives you reliable infrastructure for data extraction workflows, whether you’re using Stagehand or Playwright.
  • Scale data extraction across concurrent sessions without managing infrastructure
  • Browse protected sites with Browserbase’s Verified
  • Rotate IPs and geolocations with proxies
  • Debug and monitor extraction runs with session recordings and live views
Need scheduled or webhook-triggered data collection? Functions let you deploy data extraction workflows that can be invoked on-demand or on a schedule—perfect for building data pipelines and monitoring workflows.

Template

Get started quickly with a ready-to-use data extraction template.

Company Value Prop Generator

Clone, configure, and run in minutes

Example: Extracting a book catalog

To demonstrate data extraction with Browserbase, this example pulls book titles, prices, and availability from a sample catalog site.

Code example

import { Stagehand } from "@browserbasehq/stagehand";
import { z } from "zod";
import dotenv from "dotenv";
dotenv.config();

const stagehand = new Stagehand({
    env: "BROWSERBASE",
    verbose: 0,
});

async function scrapeBooks() {
    await stagehand.init();
    const page = stagehand.context.pages()[0];

    await page.goto("https://books.toscrape.com/");

    const scrape = await stagehand.extract({
        instruction: "Extract the books from the page",
        schema: z.object({
            books: z.array(z.object({
                title: z.string(),
                price: z.string(),
                image: z.string(),
                inStock: z.string(),
                link: z.string(),
            }))
        }),
    });

    console.log(scrape.books);

    await stagehand.close();
}

scrapeBooks().catch(console.error);

Example output

[
  {
    title: 'A Light in the Attic',
    price: '£51.77',
    image: 'https://books.toscrape.com/media/cache/2c/da/2cdad67c44b002e7ead0cc35693c0e8b.jpg',
    inStock: 'In stock',
    link: 'catalogue/a-light-in-the-attic_1000/index.html'
  },
  ...
]

Best practices for data extraction

Follow these best practices to build reliable, efficient, and ethical data extraction workflows with Browserbase.

Ethical data collection

  • Respect robots.txt: Check the website’s robots.txt file for crawling guidelines
  • Rate limiting: Implement reasonable delays between requests (2-5 seconds)
  • Terms of Service: Review the website’s terms of service before extracting data
  • Data usage: Only collect and use data in accordance with the website’s policies

Performance optimization

  • Batch processing: Process multiple pages in batches with concurrent sessions
  • Selective extraction: Only extract the data you need
  • Resource management: Close browser sessions promptly after use
  • Connection reuse: Reuse browsers for sequential extraction tasks

Protected sites

  • Enable Browserbase Verified: Recognized by bot protection partners
  • Randomize behavior: Add variable delays between actions
  • Use proxies: Rotate IPs to distribute requests
  • Mimic human interaction: Add realistic mouse movements and delays
  • Handle CAPTCHAs: Enable Browserbase’s automatic CAPTCHA solving

Next steps

Verified

Configure fingerprinting and CAPTCHA solving

Browser Contexts

Persist cookies and session data

Proxies

Configure IP rotation and geolocation

Browserbase Functions

Deploy data extraction workflows as cloud functions