Automate a web task in natural language with Stagehand
Stagehand's starter project scripts a browser with plain-English instructions. act, extract and observe handle single steps, and agent runs a multi-step task on its own.
The problem
Hand-written Playwright or Selenium selectors break when a site changes its layout. Describing each step in natural language makes scrapers and form-fillers less fragile.
Steps
- Scaffold a project with npx create-browser-app.
- cd into the new folder and copy .env.example to .env.
- Add a model provider key, such as OPENAI_API_KEY, and BROWSERBASE_API_KEY if you want cloud browsers.
- Edit the script to use act for clicks, extract for structured data and observe to list what's on the page.
- Run it with npm start.
From the official docs
await stagehand.act("Click the 'Evals' button.");
const extractResult = await stagehand.extract("Extract the value proposition from the page.");
const observeResult = await stagehand.observe("What can I click on this page?");
Results
- A TypeScript script that clicks, extracts and inspects pages from short instructions.
- agent.execute runs multi-step goals with a computer-use model.
- The same script runs on a local browser or on Browserbase cloud browsers.
As reported by the source (Stagehand docs); AgentGid did not measure these figures.
This suits a developer comfortable with TypeScript and Node who wants sturdier scrapers or form-fillers, and who can supply a model API key. Model usage is billed separately from the free MIT library, so costs scale with how many pages and agent runs you do, and Browserbase cloud browsers are only needed if you skip local ones. Browser Use (Free) ranks one place higher and is also open source.
The agent used here
Similar use cases
How The AA answered routine trading questions in Teams with Databricks Genie
UK roadside assistance provider The AA used the Genie Conversation API to answer trading teams' routine data questions inside Microsoft Teams. Databricks reports faster answers to…
Databricks reports a 70% efficiency gain in answering routine queries.
How Spotify migrated about 1,800 data pipelines with its Honk background coding agent
Spotify used Honk, its internal background coding agent built on Claude Code capabilities, to move downstream consumers off two deprecated datasets. The agent opened 240 migration…
As reported by Spotify, the team 'successfully rolled out 240 automated migration PRs using Fleetshift'.
How NBIM rolled out Claude to investment and compliance staff
NBIM, which manages Norway's sovereign wealth fund, deployed Claude across investment research, ESG analysis, compliance and data operations. Anthropic reports weekly time savings…
According to Anthropic, employees save 20% of their week on the analytical and operational work they now do with Claude.