Skip to main content
Give your agent two web tools and a simple rule: read with Fetch, interact with Browser. Fetch returns any page as markdown in one request. Browser runs a real cloud browser that your code drives step by step, for tasks like logging in, filling a form or clicking through a flow. Uses: Fetch with Adaptive Stealth Mode (mode=auto) and response_type=markdown, Browser with Playwright

How it works

  1. The agent describes the task. A read-only task is a URL. An interactive task is a URL plus a list of steps (fill, click, wait_for_text, goto).
  2. The router picks the primitive. No steps: the task goes to Fetch with mode=auto, which renders JavaScript and switches to premium proxies only when the page needs them. Steps: the task goes to Browser.
  3. Fetch returns markdown. One request, one page, ready for the model’s context.
  4. Browser runs the steps. Playwright connects to wss://browser.zenrows.com over CDP, runs each step in order, returns the page text, and closes the session.
Reading is the common case and Fetch is the fast, low-cost path for it. Browser is there for every task that needs a session with state.

Ask your AI agent

With the Zenrows MCP server connected to Claude, Cursor or any MCP client, your agent already has both paths: fast reading and a full browser. Paste this prompt:

Build the router

Install the dependencies: pip install requests playwright for Python, or npm install playwright-core for Node.js. Browser runs in the cloud, so there is no local browser to download.
The finally block closes the browser on every path, so no session stays open after the task. The login page uses the demo credentials shown on scrapingcourse.com/login.

Expose it as agent tools

Give the model the two functions as tools. The definitions use JSON Schema, which every agent framework accepts: pass input_schema as-is to the Anthropic API, or rename it to parameters for OpenAI function calling and most other frameworks.
Python
The tool descriptions carry the routing rule, so the model picks read_page for reading and browser_task only when a step needs interaction. For a complete agent loop around these tools, see Build a research agent with live web data.

Example output

Output of the router, one Fetch task and one Browser task:

Customize it

Troubleshooting

  • A click step times out waiting for navigation: the click submits a form. Keep no_wait_after=True (noWaitAfter: true in Node.js) on clicks and follow them with a wait_for_text step for text on the next page.
  • wait_for_text times out: the text never appeared, often because the previous step failed (wrong credentials, wrong selector). Return page.evaluate("document.body.innerText") in the error to see what the page shows.
  • The model uses the browser for simple reads: tighten the browser_task description, for example “Only call this when a step needs a click, a form or a login.”
  • Fetch returns 422: the page wasn’t retrieved. Keep mode=auto and set the client timeout to 180 seconds so it has time to escalate, see error codes.

Build a research agent with live web data

Wire Zenrows tools into an LLM agent loop.

Log in once and reuse the session

Save the logged-in state and reuse it across sessions.

Connect Playwright or Puppeteer to Zenrows Browser

Every connection option for Browser.

Connect your AI agent to Zenrows

Give Claude, Cursor or your own agent live web access.