The Problem
Amazon doesn't expose a clean invoice export API for every purchasing workflow, so invoice data collection often falls back to someone manually opening each order page and copying numbers into a spreadsheet: tedious, error prone, and the first thing to get skipped when someone's busy.
Architecture
Nightly Schedule → Filter Today's Invoice Rows (Google Sheets) → Per Row Loop: Airtop Cloud Browser (open invoice URL, zoom, screenshot) → Upload to Google Drive (current month folder) → OpenAI Vision extracts fields → Structured JSON (autofixing parser) → Append to Month Named Sheet Tab
What It Does
A real browser session, not a scraper fighting anti bot measures: Airtop drives an actual authenticated cloud browser against Amazon's UI, which is more resilient to layout and anti automation changes than a raw HTTP scraper would be, at the cost of running an actual browser per invoice.
Vision extraction with a self correcting parser: OpenAI reads the invoice screenshot directly rather than needing a text extraction step first, and the output goes through an autofixing structured output parser that retries on malformed JSON instead of failing the whole row.
Automatic monthly filing, both in Drive and in Sheets: screenshots land in a Drive folder named for the current month, and extracted data lands in a matching month named spreadsheet tab, so records are organized by period without anyone manually creating folders.
Date filtered, not full table processing: only today's rows are pulled from the source sheet each run, which keeps the nightly job bounded regardless of how large the invoice log grows.
Engineering Focus
The part worth studying is the choice to screenshot then vision rather than parse Amazon's HTML directly: it trades raw speed for resilience against the exact kind of markup churn that breaks HTML scrapers on a random Tuesday, which is usually the right trade for something running unattended every night.
What I'd Harden
Before production I'd want: a dead letter mechanism for rows that fail extraction after the autofix retry (right now a persistent failure likely just drops silently), rate limiting on the Airtop session loop to avoid tripping Amazon's own bot detection, and a reconciliation check comparing extracted totals against the source order amount before the row is trusted downstream.
Gallery


