Why AI changes browser automation
Selenium, Playwright and Puppeteer scripts click buttons, fill forms and extract data. They work until the page structure changes, a captcha appears or the workflow needs judgment. Then someone updates selectors, again.
An LLM changes the failure mode. Automation that understands content adapts and decides from context:
- A scraper that reads the page instead of hunting CSS classes.
- A form filler that finds the right field even with obfuscated IDs.
- Navigation driven by a described goal instead of CSS paths.
- Teams already run this for lead generation and competitive intelligence.
The core pattern: page in, structured JSON out
Every technique in this guide is one pattern. Get this loop solid once and scraping, form filling and navigation are just different prompts.
- Load the page with Puppeteer.
- Extract visible text without scripts and styles, capped in length. Add structure if needed.
- Prompt with exact JSON fields and ask for valid JSON only.
- Parse, act and handle the parse failure path, because it will happen.
- Pre-filter hard so you pay for signal instead of boilerplate.
- Validate every response before anything downstream trusts it.
Scraping that survives redesigns
Traditional scraping binds to markup. When the price class changes, the script silently breaks. Semantic extraction binds to meaning: ask for name, price, currency, availability and rating as JSON, whatever the markup.
The model knows "$1,299.00", "1299 USD" and "From $1,299" are the same price. That replaces a wall of conditionals.
It extracts articles too: title, author, date, full text and topics from any layout. That is the input an agent pipeline or lead-scoring model wants.