Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions python-examples/stagehand/api/get-books.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Params(TypedDict):
class BookDetails(BaseModel):
title: str
price: str
rating: str | None = None
availability: str | None = None


Expand Down Expand Up @@ -76,7 +75,7 @@ async def automation(page: Page, params: Params, **_kwargs):
)
session_id = session.data.session_id
print(f"✅ Session started: {session_id}")
print("\nInitialized 🤘 Stagehand")
print("\nInitialized Stagehand")

category = params.get("category")
all_books: list[BookDetails] = []
Expand Down Expand Up @@ -113,7 +112,7 @@ async def automation(page: Page, params: Params, **_kwargs):
# Extract all book details from the current page using simple JSON schema
result = await client.sessions.extract(
id=session_id,
instruction="Extract all books on this page including title, price, rating and availability for each book",
instruction="Extract all books on this page including title, price and availability for each book",
options={"model": model_config},
schema={
"type": "object",
Expand All @@ -125,7 +124,6 @@ async def automation(page: Page, params: Params, **_kwargs):
"properties": {
"title": {"type": "string"},
"price": {"type": "string"},
"rating": {"type": "string"},
"availability": {"type": "string"},
},
"required": ["title", "price"],
Expand Down Expand Up @@ -172,7 +170,7 @@ async def automation(page: Page, params: Params, **_kwargs):
break
finally:
# Cleanup Stagehand
print("\nClosing 🤘 Stagehand...")
print("\nClosing Stagehand...")
await client.sessions.end(session_id)
print("✅ Session ended")

Expand Down
7 changes: 3 additions & 4 deletions typescript-examples/stagehand/api/get-books.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const bookDetailsSchema = z.object({
z.object({
title: z.string(),
price: z.string(),
rating: z.string().optional(),
availability: z.string().optional(),
})
),
Expand Down Expand Up @@ -71,7 +70,7 @@ export default async function handler(
}
});
await stagehand.init();
console.log("\nInitialized 🤘 Stagehand");
console.log("\nInitialized Stagehand");

await page.setViewportSize({ width: 1280, height: 800 });

Expand Down Expand Up @@ -100,7 +99,7 @@ export default async function handler(

// Extract all book details from the current page
const result = await stagehand.extract(
"Extract all books visible on the page with their complete details including title, price, rating, and availability",
"Extract all books visible on the page with their complete details including title, price and availability",
bookDetailsSchema,
);
allBooks.push(...result.books ?? []);
Expand Down Expand Up @@ -138,7 +137,7 @@ export default async function handler(
}
} finally {
// Cleanup Stagehand
console.log("\nClosing 🤘 Stagehand...");
console.log("\nClosing Stagehand...");
await stagehand.close();
}

Expand Down
Loading