Skip to main content
Automate the extraction of financial data from investor relations websites by combining Stagehand for AI-powered browser automation with Reducto for PDF processing.

Overview

This cookbook demonstrates how to:
  1. Navigate to Apple.com’s investor relations section using Stagehand AI actions
  2. Automatically download PDFs when links are clicked
  3. Poll the Browserbase Downloads API until the file is ready
  4. Extract the PDF from the ZIP archive downloaded from Browserbase
  5. Upload the PDF to Reducto and extract structured iPhone net sales data
  6. Output the extracted financial data as formatted JSON

Prerequisites

Before starting, you need: Install the required packages:
Set your environment variables:

Step-by-step breakdown

Step 1: Initialize Stagehand and create a session

Stagehand provides AI-powered browser automation on top of Browserbase. Initialize the clients and start a session:

Step 2: Navigate and trigger download with AI actions

Use Stagehand’s AI-powered actions to navigate the page naturally using plain English instructions:
Browserbase automatically captures file downloads when links are clicked.

Step 3: Poll the Downloads API

Browserbase stores downloads and makes them available through the Downloads API. Poll until the download completes:

Step 4: Extract PDF from ZIP

Browserbase returns downloads as a ZIP archive. Extract the PDF:

Step 5: Extract data with Reducto

Upload the PDF to Reducto and extract structured financial data using a schema:

Step 6: Output results

The extracted data is returned as structured JSON matching your schema:

Full implementation

For the complete implementation with all helper functions, error handling, and Reducto extraction schema, see the full source code on GitHub.

Resources

Browserbase Template

View the original Browserbase template

Source Code

Full source code on GitHub

Extract API

Learn more about Reducto’s Extract API

Array Extraction

Extract multiple records from documents