DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to pull structured data from a site with a schema with Stagehand

Use extract with a Zod or Pydantic schema to get typed data out of any page.

Short answer: Install with pnpm add @browserbasehq/stagehand 'zod@~4.4.3' or pip install stagehand; then launch a local browser and create a Stagehand instance with your model and API key; Navigate with page.goto to the page you want. All steps.

Credentials. You supply a model API key and every extract call costs tokens; keep keys in environment variables, not in code.

Who it is forA developer who needs a table of prices, invoices or listings from a site with no API.

The problemHand-written scrapers break whenever the page layout changes and return messy text.

The outcomeSchema-validated JSON from the page, ready to save or feed into another system.

What you need first

  • Node with pnpm, Python, or Go
  • Chrome installed for local runs
  • A model API key such as OPENAI_API_KEY, or a Browserbase API key to use the Model Gateway

Steps

  1. Install with pnpm add @browserbasehq/stagehand 'zod@~4.4.3' or pip install stagehand
  2. Launch a local browser and create a Stagehand instance with your model and API key
  3. Navigate with page.goto to the page you want
  4. Call Stagehand.extract with an instruction such as extract every invoice in the table and a schema describing the fields
  5. Use the returned data, which is validated against your schema

Prompt for your agent

Using browserbase/stagehand in <TypeScript or Python>, write a script that opens <url>, extracts every <item> on the page into a schema with fields <fields>, and saves the result as JSON. Read the API key from the environment.

Caveat. Respect each site's terms of service and robots rules when you extract data.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for browserbase/stagehand and "Pull structured data from a site with a schema"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer