proxy_country, proxy_region and session_ttl
Ask your AI agent
With the Zenrows MCP server connected to Claude, Cursor or any MCP client, paste this prompt. Your agent picks the right Zenrows tools and settings on its own.Connect and open a page
Every connection starts a new browser session. Use the WebSocket URLwss://browser.zenrows.com?apikey=YOUR_ZENROWS_API_KEY wherever you would launch a local browser, and close the browser when you finish so the session ends right away.
browser.contexts[0] (Python) or browser.contexts()[0] (Node.js) is the natural place for new pages. Installing playwright-core or puppeteer-core is enough: the browser runs in the cloud, so you skip the local browser download.
Choose the country, region and session lifetime
Add parameters to the WebSocket URL:
Use either
proxy_country or proxy_region on a connection. This example opens a US session that lives for two minutes and prints the IP the target site sees:
Build the URL with the Zenrows Browser SDK
In Node.js, the@zenrows/browser-sdk package builds and validates the URL for you. sessionTTL takes seconds, for example 120, and proxy.location takes a ProxyCountry or ProxyRegion value.
Node.js (SDK)
new ScrapingBrowser() with no arguments reads the key from the ZENROWS_API_KEY environment variable.
Example output
From the US session above (the IP changes on every session):Customize it
Troubleshooting
page.gototimes out waiting forload: a heavy asset on the page is still loading. Passwait_until="domcontentloaded"(Python) or{ waitUntil: "domcontentloaded" }(Node.js), then wait for the element you need.- The session closes in the middle of a long task: the session reached its lifetime. Raise
session_ttl, for example&session_ttl=15m. - Usage keeps growing after your script ends: the session stayed open until its lifetime ran out. Call
browser.close()in afinallyblock on every path. - 401 when connecting: the API key in the URL is wrong or missing. Copy it again from the Browser dashboard.
Related recipes
Log in once and reuse the session
Save cookies after one login and start every next session signed in.
Run browser sessions in parallel
Open several cloud browsers at once with a concurrency limit.
Build a browser agent with Zenrows
Let Claude or GPT drive the browser with the Zenrows tools.
Let your AI assistant browse with Browser tools
Drive the browser from Claude, Cursor or the CLI.