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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store
.env
cursorrules.md
.cursorrules
.cursorrules
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ A comprehensive collection of ready-to-use automation templates demonstrating th
## 📚 Resources

### Documentation
- **Stagehand Docs**: https://docs.browserbase.com/stagehand
- **Stagehand Docs**: https://docs.stagehand.dev/v3/first-steps/introduction
- **Browserbase Docs**: https://docs.browserbase.com
- **API Reference**: https://docs.browserbase.com/api

Expand Down
5 changes: 3 additions & 2 deletions python/business-lookup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
• Multi-registry support: Extend agent to search across multiple city or state business registries with routing logic.

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
💡 Templates: https://www.browserbase.com/templates
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://www.browserbase.com/templates
📧 Need help? [email protected]

2 changes: 1 addition & 1 deletion python/business-lookup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ class BusinessInfo(BaseModel):
print("Common issues:")
print(" - Check .env file has BROWSERBASE_PROJECT_ID and BROWSERBASE_API_KEY")
print(" - Verify GOOGLE_API_KEY is set for the agent")
print("Docs: https://docs.browserbase.com/stagehand")
print("Docs: https://docs.stagehand.dev/v3/first-steps/introduction")
exit(1)

4 changes: 2 additions & 2 deletions python/context/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
• Secure lifecycle: Rotate, refresh, and delete contexts programmatically to enforce security policies.

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.browserbase.com/stagehand
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://github.com/browserbase/stagehand/tree/main/examples
🔧 Templates: https://www.browserbase.com/templates
📧 Need help? [email protected]
2 changes: 1 addition & 1 deletion python/context/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@ class UserData(BaseModel):
print(" - Check .env file has SF_REC_PARK_EMAIL and SF_REC_PARK_PASSWORD")
print(" - Verify BROWSERBASE_PROJECT_ID and BROWSERBASE_API_KEY are set")
print(" - Ensure credentials are valid for SF Rec & Park")
print("Docs: https://docs.browserbase.com/stagehand")
print("Docs: https://docs.stagehand.dev/v3/first-steps/introduction")
exit(1)
57 changes: 57 additions & 0 deletions python/council-events/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Stagehand + Browserbase: Philadelphia Council Events Scraper

## AT A GLANCE
- Goal: automate extraction of Philadelphia Council events for 2025 from the official calendar.
- Flow: navigate to phila.legistar.com → click calendar → select 2025 → extract event data (name, date, time).
- Benefits: quickly gather upcoming council events without manual browsing, structured data ready for analysis or notifications.
Docs → https://docs.stagehand.dev/v3/first-steps/introduction

## GLOSSARY
- act: perform UI actions from a prompt (click, select, navigate).
Docs → https://docs.stagehand.dev/basics/act
- extract: pull structured data from a page using AI and Pydantic schemas.
Docs → https://docs.stagehand.dev/basics/extract
- Pydantic schema: type-safe data models that validate extracted content.

## QUICKSTART
1) cd council-events
2) python -m venv venv
3) source venv/bin/activate # On Windows: venv\Scripts\activate
4) pip install stagehand python-dotenv pydantic
5) cp .env.example .env
6) Add your Browserbase API key, Project ID, and OpenAI API key to .env
7) python main.py

## EXPECTED OUTPUT
- Initializes Stagehand session with Browserbase
- Navigates to Philadelphia Council calendar
- Selects 2025 events from dropdown
- Extracts event names, dates, and times
- Displays structured JSON output with all events
- Provides live session URL for monitoring
- Closes session cleanly

## COMMON PITFALLS
- "ModuleNotFoundError": ensure all dependencies are installed via pip
- Missing credentials: verify .env contains BROWSERBASE_PROJECT_ID, BROWSERBASE_API_KEY, and OPENAI_API_KEY
- No events found: check if the website structure has changed or if 2025 calendar is available
- Network issues: ensure internet access and phila.legistar.com is accessible
- Import errors: activate your virtual environment if you created one

## USE CASES
• Civic monitoring: Track upcoming council meetings, hearings, and votes for advocacy or journalism.
• Event aggregation: Pull council calendars into dashboards, newsletters, or community notification systems.
• Research & analysis: Collect historical event data to analyze meeting frequency, topics, or scheduling patterns.

## NEXT STEPS
• Multi-year extraction: Loop through multiple years to build historical event database.
• Event details: Click into individual events to extract agendas, attendees, and documents.
• Notifications: Set up scheduled runs to detect new events and send alerts via email/Slack.

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://github.com/browserbase/stagehand/tree/main/examples
📧 Need help? [email protected]

113 changes: 113 additions & 0 deletions python/council-events/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Stagehand + Browserbase: Philadelphia Council Events Scraper - See README.md for full documentation

import os
import asyncio
from dotenv import load_dotenv
from stagehand import Stagehand, StagehandConfig
from pydantic import BaseModel, Field
from typing import List

# Load environment variables
load_dotenv()


class Event(BaseModel):
"""Single event with name, date, and time"""
name: str = Field(..., description="the name of the event")
date: str = Field(..., description="the date of the event")
time: str = Field(..., description="the time of the event")


class EventResults(BaseModel):
"""Collection of events extracted from the calendar"""
results: List[Event] = Field(..., description="array of events")


async def main():
"""
Searches Philadelphia Council Events for 2025 and extracts event information.
Uses AI-powered browser automation to navigate and interact with the site.
"""
print("Starting Philadelphia Council Events automation...")

# Initialize Stagehand with Browserbase for cloud-based browser automation
config = StagehandConfig(
env="BROWSERBASE",
api_key=os.environ.get("BROWSERBASE_API_KEY"),
project_id=os.environ.get("BROWSERBASE_PROJECT_ID"),
model_name="openai/gpt-4.1",
model_api_key=os.environ.get("OPENAI_API_KEY"),
verbose=1,
# 0 = errors only, 1 = info, 2 = debug
# (When handling sensitive data like passwords or API keys, set verbose: 0 to prevent secrets from appearing in logs.)
# https://docs.stagehand.dev/configuration/logging
)

try:
# Use async context manager for automatic resource management
async with Stagehand(config) as stagehand:
print("Initializing browser session...")
print("Stagehand session started successfully")

# Provide live session URL for debugging and monitoring
session_id = None
if hasattr(stagehand, 'session_id'):
session_id = stagehand.session_id
elif hasattr(stagehand, 'browserbase_session_id'):
session_id = stagehand.browserbase_session_id

if session_id:
print(f"Watch live: https://browserbase.com/sessions/{session_id}")

page = stagehand.page

# Navigate to Philadelphia Council
print("Navigating to: https://phila.legistar.com/")
await page.goto("https://phila.legistar.com/")
print("Page loaded successfully")

# Click calendar from the navigation menu
print("Clicking calendar from the navigation menu")
await page.act("click calendar from the navigation menu")

# Select 2025 from the month dropdown
print("Selecting 2025 from the month dropdown")
await page.act("select 2025 from the month dropdown")

# Extract event data using AI to parse the structured information
print("Extracting event information...")
results = await page.extract(
"Extract the table with the name, date and time of the events",
schema=EventResults
)

print(f"Found {len(results.results)} events")
print("Event data extracted successfully:")

# Display results in formatted JSON
import json
print(json.dumps(results.model_dump(), indent=2))

print("Session closed successfully")

except Exception as error:
print(f"Error during event extraction: {error}")

# Provide helpful troubleshooting information
print("\nCommon issues:")
print("1. Check .env file has BROWSERBASE_PROJECT_ID and BROWSERBASE_API_KEY")
print("2. Verify OPENAI_API_KEY is set in environment")
print("3. Ensure internet access and https://phila.legistar.com is accessible")
print("4. Verify Browserbase account has sufficient credits")
print("5. Check if the calendar page structure has changed")

raise


if __name__ == "__main__":
try:
asyncio.run(main())
except Exception as err:
print(f"Application error: {err}")
exit(1)

4 changes: 3 additions & 1 deletion python/form-filling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
• Handle complex widgets: Add file uploads, multi-step flows, dropdown/radio/datepickers, and basic anti-bot tactics (delays/proxies).

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.browserbase.com/stagehand
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://www.browserbase.com/templates
📧 Need help? [email protected]
2 changes: 1 addition & 1 deletion python/form-filling/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ async def main():
print("Common issues:")
print(" - Check .env file has BROWSERBASE_PROJECT_ID and BROWSERBASE_API_KEY")
print(" - Ensure form fields are available on the contact page")
print("Docs: https://docs.browserbase.com/stagehand")
print("Docs: https://docs.stagehand.dev/v3/first-steps/introduction")
exit(1)
6 changes: 4 additions & 2 deletions python/gemini-cua/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
• Extend capabilities: Add support for file downloads, form submissions, and more complex interaction patterns.

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.stagehand.dev/first-steps/introduction
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
📧 Need help? [email protected]
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://www.browserbase.com/templates
📧 Need help? [email protected]
2 changes: 1 addition & 1 deletion python/gemini-cua/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@ async def main():
print("Common issues:")
print(" - Check .env file has BROWSERBASE_PROJECT_ID and BROWSERBASE_API_KEY")
print(" - Verify GOOGLE_API_KEY is set for the agent")
print("Docs: https://docs.browserbase.com/stagehand")
print("Docs: https://docs.stagehand.dev/v3/first-steps/introduction")
exit(1)
5 changes: 3 additions & 2 deletions python/gift-finder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
• Scale & geo-test: Fan out more concurrent sessions and run a geo matrix via proxies (e.g., UK/EU/US) to compare localized inventory and pricing.

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.browserbase.com/stagehand
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
🛍️ Gift Ideas: https://firebox.eu/
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://www.browserbase.com/templates
📧 Need help? [email protected]
4 changes: 3 additions & 1 deletion python/license-verification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
• Persist & integrate: Store structured results in a database or push directly into CRM/compliance systems.

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.browserbase.com/stagehand
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://www.browserbase.com/templates
📧 Need help? [email protected]
59 changes: 59 additions & 0 deletions python/nurse-verification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Stagehand + Browserbase: Nurse License Verification

## AT A GLANCE
- Goal: automate verification of nurse licenses by filling forms and extracting structured results from verification sites.
- Flow: loop through license records → navigate to verification site → fill form → search → extract verification results.
- Benefits: quickly verify multiple licenses without manual form filling, structured data ready for compliance tracking or HR systems.
Docs → https://docs.stagehand.dev/basics/act

## GLOSSARY
- act: perform UI actions from a prompt (type, click, fill forms).
Docs → https://docs.stagehand.dev/basics/act
- extract: pull structured data from a page using AI and Pydantic schemas.
Docs → https://docs.stagehand.dev/basics/extract
- schema: a Pydantic model that enforces data types, optional fields, and validation rules.
Docs → https://docs.pydantic.dev/
- license verification: process of confirming the validity and status of professional licenses.

## QUICKSTART
1) cd nurse-verification
2) python -m venv venv
3) source venv/bin/activate # On Windows: venv\Scripts\activate
4) pip install stagehand python-dotenv pydantic
5) cp .env.example .env
6) Add your Browserbase API key, Project ID, and OpenAI API key to .env
7) python main.py

## EXPECTED OUTPUT
- Initializes Stagehand session with Browserbase
- Loops through license records in LICENSE_RECORDS array
- For each record: navigates to verification site, fills form, searches
- Extracts verification results: name, license number, status, info URL
- Displays structured JSON output with all verification results
- Provides live session URL for monitoring
- Closes session cleanly

## COMMON PITFALLS
- "ModuleNotFoundError": ensure all dependencies are installed via pip
- Missing credentials: verify .env contains BROWSERBASE_PROJECT_ID, BROWSERBASE_API_KEY, and OPENAI_API_KEY
- No results found: check if license numbers are valid or if verification site structure has changed
- Network issues: ensure internet access and verification sites are accessible
- Schema validation errors: ensure extracted data matches Pydantic schema structure
- Import errors: activate your virtual environment if you created one

## USE CASES
• HR compliance: Automate license verification for healthcare staff onboarding and annual reviews.
• Healthcare staffing: Verify credentials of temporary or contract nurses before assignment.
• Regulatory reporting: Collect license status data for compliance reporting and audits.

## NEXT STEPS
• Multi-site support: Add support for different license verification sites and adapt form filling logic.
• Batch processing: Load license records from CSV/Excel files for large-scale verification.
• Status monitoring: Set up scheduled runs to track license status changes and expiration dates.

## HELPFUL RESOURCES
📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction
🎮 Browserbase: https://www.browserbase.com
💡 Try it out: https://www.browserbase.com/playground
🔧 Templates: https://www.browserbase.com/templates
📧 Need help? [email protected]
Loading