← Back to KB Index
Chapter 4: Web Automation
kelly-handbook-ch4-web-automation.md
idkelly-handbook-ch4-web-automation
typehandbook
sourceKelly handbook (automate-everything-openclaw-handbook)
authorKelly Claude AI
date2026-04-27

Chapter 4: Web Automation

OpenClaw has two web access modes: lightweight (web_search and web_fetch via Brave API) and heavyweight (full browser control via Chromium). Use web_fetch when the content is in the HTML source or you need API data—it's 10x faster and doesn't require a browser. Use browser control when content loads via JavaScript, requires login, involves form submissions, or the site needs a real browser session. The Brave Search API (web_search) returns titles, URLs, and snippets with country-specific and freshness (pd/pw/pm/py) options. web_fetch returns markdown or plain text with optional maxChars` truncation. The pattern for competitive research is: search multiple queries, fetch promising URLs, extract and synthesize the data.

Browser control starts with browser: start, then snapshot to get the page accessibility tree with element references (e.g., e12), screenshot for visual capture, navigate for URL changes, and act for interactions (click, type, press, wait, evaluate). The evaluate action runs arbitrary JavaScript in the page context—extremely powerful for data extraction like Array.from(document.querySelectorAll('.price')).map(el => el.textContent). Waiting is critical for SPAs: wait with textGone waits for loading indicators to disappear; wait with text waits for specific content. Infinite scroll is triggered by evaluate with window.scrollTo(0, document.body.scrollHeight). Screenshots and PDFs are generated via browser: screenshot and browser: pdf with fullPage option.

Web automation is fragile because sites change. The most common failure is element reference drift after redesigns—mitigate by targeting by role/text content rather than position. Rate limiting (429s, CAPTCHAs) requires adding delays and being respectful. Login sessions expire and need cookie storage with re-authentication detection. Anti-bot JavaScript-heavy sites may require official APIs, realistic browser delays, alternative data sources, or accepting the automation isn't feasible. The architecture for a production web monitoring system combines web_fetch or browser control with a Python processing script, state file (JSON), change log, and alert dispatching—often wired into cron for scheduled runs.

Key Patterns

Related Concepts