From c6acf3e3412623b8e4603a5644902ac0a57262fb Mon Sep 17 00:00:00 2001 From: Steven Bryan Date: Fri, 19 Sep 2025 12:15:21 -0700 Subject: [PATCH] Fix python installation instructions --- docs/first-steps/installation.mdx | 38 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/docs/first-steps/installation.mdx b/docs/first-steps/installation.mdx index df6272683..4ea17c804 100644 --- a/docs/first-steps/installation.mdx +++ b/docs/first-steps/installation.mdx @@ -95,6 +95,26 @@ main().catch((err) => { + +For uv installation instructions see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1). + + +### Initialize virtual environment + + + +```bash uv +uv init my-stagehand-project +cd my-stagehand-project +``` + +```bash pip +python -m venv venv +source venv/bin/activate # On Windows: venv\Scripts\activate +``` + + + ### Add dependencies @@ -128,6 +148,10 @@ BROWSERBASE_PROJECT_ID=your_project_id import os import asyncio from stagehand import Stagehand +from pydantic import BaseModel + +class PageData(BaseModel): + title: str async def main(): stagehand = Stagehand( @@ -143,16 +167,12 @@ async def main(): await page.act("Click the sign in button") # Extract structured data - result = await page.extract({ - "instruction": "extract the page title", - "schema": { - "title": { - "type": "string" - } - } - }) + result = await page.extract( + instruction = "extract the page title", + schema = PageData + ) - print(result["title"]) + print(result.title) await stagehand.close() if __name__ == "__main__":