Some information genuinely has no API — a specific vendor's product page, a government portal, a site that only exposes data through its UI. Autonomous browser agents exist for exactly that gap: instead of calling an endpoint, the agent drives a real browser, reading the current page and deciding its next click or keystroke the way a person navigating the site would.
Setting up a browser agent
1. Give the agent a real browser session. Tools like browser-use wrap a controllable browser (via Playwright under the hood) that the agent can navigate, click within, and read from.
2. Let the model reason over the page state, not raw HTML. The agent typically works from a simplified, LLM-friendly representation of visible elements rather than the full DOM, which keeps token usage manageable.
3. Give it a clear task and a stopping condition. Without a defined "done" state, a browser agent can loop indefinitely clicking around a site — define what result you're actually looking for.
# Autonomous browser agent using browser-use
import asyncio
from browser_use import Agent
from langchain_openai import ChatOpenAI
async def main():
agent = Agent(
task="Go to a hardware store site and find the current price of a 20V cordless drill",
llm=ChatOpenAI(model="gpt-4o"),
)
result = await agent.run()
print(result)
asyncio.run(main())
| Approach | Works without a public API? | Reliability |
|---|---|---|
| Direct API call | No — requires the site to expose one | High — stable, structured responses |
| Autonomous browser agent | Yes — works on any UI a human could use | Lower — breaks if the page layout changes significantly |
The trade-off is real: a browser agent is slower, more token-hungry, and more fragile than a direct API integration. Reach for it specifically when no API exists — not as a default way to automate web tasks that already have a cleaner path.
Practical Challenge
Pick a site you know has no public API, give a browser agent a specific, narrow task on it (e.g. "find the return policy"), and define exactly what a successful "done" result should look like before running it.
Concept Check
Sources & Further Reading
- browser-use (GitHub) — the open-source browser automation library used in this article's example.
AI