--- name: web-content-acquisition description: Use when fetching a URL's content headlessly (page or doc). --- # Fetching URL content headlessly Class: turn a URL into the document's actual text. Do not open a GUI browser to *look* at it — in a headless CLI there is no window to show. Pick the cheapest reliable retrieval and validate each one. ## Method order (cheapest first; confirm each works before moving on) 1. **Shared doc → no-JS export endpoint** (works for anyone-with-link Google Docs/Sheets/Slides; no JS, no login). - Docs: `https://docs.google.com/document/d//export?format=txt` (also `docx`, `pdf`) - Sheets: `https://docs.google.com/spreadsheets/d//export?format=csv` - Success signal: HTTP 200, `content-type: text/plain`, or a redirect to `*.googleusercontent.com` with real bytes back. A login/consent redirect instead = private doc → go to 2/3. 2. **web_extract** — only when `web.extract_backend` is a *content* backend (firecrawl / tavily / keenable / exa / parallel). A search-only backend (e.g. brave-free) cannot fetch page content and errors out; that is a config gap, not a dead end — point the backend at a content provider and it works. 3. **Browser (agent-browser)** — for interactive/JS-only pages, or when the user needs the editable UI. Getting a runnable browser on this Termux/Android host is non-trivial — see `references/setup-termux.md`, and prefer 1/2 whenever the content is reachable without it. ## Standing gotchas (this host) - No `/tmp`. Write downloads and exports to the scratch dir (`$BH_AGENT_WORKSPACE` or `~/.hermes/cache/scratch`); a `curl -o /tmp/...` will fail with a write error. - `os.platform()` here is `android`; binaries and tools that assume `linux`, or a platform they don't ship, mis-resolve. Check what actually runs rather than what the name says. ## After fetching - Present the content. Offer the interactive editor path only if the user genuinely must edit (that needs their own Google login) — and say up front that the headless CLI has no GUI to display the editor in.