Skip to main content
POST /scrape opens a page in a cloud browser and returns it as cleaned HTML, Markdown, links or a screenshot. The browser has a desktop fingerprint and a proxy picked for the site, or the kind and location you set, and passes challenge pages and captchas on its own. Requests sent close together share a browser, so they are faster and share cookies. Run your own browser instead for a login across pages, your own cookies, proxy, fingerprint or extensions, proxy session options or a persistent profile. A coding agent can set this up from the setup prompt.

Scrape a page

Set your API token and base URL first.
Most pages come back in a second or two. The first request after a pause adds a few seconds to start a browser, and a challenge page adds 10 to 60 seconds. A request gets 120 seconds in total.

Which browser serves a request

Requests with the same proxy settings share browsers. A browser runs a few requests at a time, each in its own tab. A request goes to the first of:
  1. A browser already running your requests that has room, fullest first, including one still starting.
  2. The browser that served your last request. It stays up 10 seconds after that request.
  3. A new browser, if a browser slot is free.
  4. The next place that frees up.
Requests in one browser share its exit IP, cookies, passed challenges and CPU, so a page can load slower than alone. If a site refuses a browser, the browser is retired and the request is retried in a new one. A browser takes one slot however many requests it runs. A request that finds no place within about 90 seconds gets 429 parallel_browsers_limit_reached. Set your HTTP timeout to 120 seconds or more, and after a 429 send fewer requests at once. new_browser: true runs the request alone in a fresh browser, with its own exit IP and no cookies from earlier requests, stopped when the request ends. To keep working in one browser, start your own.

Recipes

Each recipe is a single request. The SDK examples reuse the client from Scrape a page: body fields go in as keyword arguments in Python or an options object in JavaScript, and the result has the fields of data from Read the response.

An article as Markdown, for an LLM

Markdown of the main content, without menus, footers and sidebars. Headings and links stay.

A product page: name and price

wait_for waits for the price. The request returns as soon as it renders, or fails with selector_timeout if it never does.
links are absolute and deduplicated. This example keeps only links to other sites.

A screenshot of a page

A screenshot is taken only when formats includes screenshot; data.screenshot then holds a Base64 PNG of the whole page. It also loads images, fonts and media, so the request usually costs about twice as much. Pass block_resources to skip what the shot can do without.

A search typed into a page

Actions run on the loaded page with human-like input: click the search box, type the query, press Enter, wait for results, scroll. You get the page as the actions left it.

A listing that loads on scroll

Wait after each scroll so the next batch can load. The result has everything loaded by the end.

A page behind Cloudflare

The challenge page is passed before the page is captured, with a captcha solve if it has one. challenge in the response says what was there and what it cost. Give the request a longer timeout for the wait. A challenge that passes by itself is free.

Pages behind a login, in one browser

POST /scrape keeps a browser only for a few seconds between requests, so for pages behind a login start your own browser. POST /profiles/{internal_uuid}/scrape takes the same body. Here the first request logs in, the second reads a page as that user. The demo site accepts any name and password.

Request parameters

POST /profiles/{internal_uuid}/scrape takes the same body, with cookies and without proxy, retry and new_browser. An unknown field returns 422 validation_error.

Proxy kind and location

type is datacenter, residential or mobile. The location takes the fields and rules of a browser’s proxy:
  • country (two letters), with optional region, city and asn
  • pool, such as europe
  • lat and lon
Both are optional and kept on every attempt. When left out:
  • No type: datacenter if it covers the country, then residential if the site refuses. A location beyond a country runs on residential. Mobile only when set.
  • No location: an exit near the region you call.
type: datacenter takes country only. Datacenter traffic is free; residential and mobile traffic is billed per GB, as in any browser. For session options or your own proxy URL, run your own browser.

Examples per option

Which wait to use

  • wait_until sets when navigation is done. The default domcontentloaded returns once the HTML is parsed, before late images and scripts, so a page drawn by scripts can still be blank in a screenshot. load waits for those too. networkidle waits for the network to go quiet and times out on pages with constant background traffic like analytics or chat widgets. commit returns on the first response, enough for a status check.
  • wait_for waits for one element. Try it first: point it at the content you need, such as a listing, a price or an article, and the request returns as soon as it appears.
  • wait is a fixed pause. Use it only when nothing on the page signals it is ready, since it adds time to every request.
  • actions are for pages that show content only after input: a search, a cookie prompt, a “load more” button, a tab. A wait action between steps waits for the result of the previous one.
A request runs in this order:
  1. Load url until wait_until, within timeout.
  2. Pause for wait seconds, then wait for wait_for, within timeout.
  3. Run actions in order.
  4. Capture formats.
After navigation and after every step the page is checked: a challenge page is passed and a captcha is solved. If a wait ended with a solve, it runs again. If a wait_for element doesn’t show up, the page is checked, and after a solve the request waits for the element once more. Actions are never interrupted or repeated: a captcha that shows up during an action is handled by the check after it.

Actions

If an action fails, the request ends with action_failed, and data has the page as the browser left it, plus challenge. If a click leads to a challenge page, the check after the click passes it.

Challenge pages and captchas

Three things can get in the way. A challenge page is what an anti-bot service shows instead of the page until the browser passes its check, usually with status 403, 405, 429 or 503. Some pass by themselves, some have a captcha. A block page is a refusal no check gets past, for example a banned exit IP, and is reported right away. A page captcha sits on the page itself and guards a form or an action. With auto_captcha_solve: true (the default) every challenge page and captcha the checks find is solved, paid types included. An invisible captcha runs only when the site calls it, usually when a form is sent. Until then there is nothing to solve and the request doesn’t wait for it; challenge shows it with solved: false if the check sees it. After a click that sends the form, the check after the click solves it. A captcha that appears after the last step isn’t seen, so end with a wait, wait_for or solve step. For a form behind a captcha you can also control the browser over CDP and call Captcha.solve yourself. Every solve is a captcha charge, whatever the outcome. A challenge page that passes by itself is free.
If your content isn’t behind a challenge page, auto_captcha_solve: false is faster: captchas on the page are left alone and not charged.
If a challenge page can’t be passed, or a block page comes up, POST /scrape retries in a fresh browser with a different exit IP, and without proxy.type then moves from datacenter to residential. A connection error (reset, closed or timed out) is retried too; a certificate error is not. A domain that doesn’t exist looks like a reset connection, so it comes back as site_unreachable after the retry. If it’s still blocked, you get the page as is with the site’s status. An unsolved page captcha doesn’t hold the request: the page comes back right away with challenge.solved: false. With retry: false a request gets one attempt, and the first refusal or error comes back as is. Challenge pages are still passed and captchas solved. Use it to run your own retries. With auto_captcha_solve: false nothing is solved or waited for. You get the page as is. challenge reports a challenge page or a block page, and a page captcha only if its widget is already drawn when the page is captured. Many widgets draw a second or two after the load, so add a wait or wait_for step if you need to know about them. To choose the moment yourself, keep false and add a solve action where you expect the captcha. It solves what’s on the page at that point, including a widget still loading, and does nothing if there’s nothing to solve. A challenge page the action can’t pass comes back as is, without a retry.

Read the response

data.status is the site’s HTTP status after redirects and solves, so a 200 from Surfsky can carry a 403 from the site. Each format you ask for adds a key: content for html, plus raw_html, markdown, links (absolute, deduplicated), screenshot (Base64) and cookies (the jar, to pass as cookies to a browser you start). Links and image addresses in content and markdown are absolute; raw_html is the document as the browser has it. If the site answered with an error and an empty body, you get that status and empty content. A PDF comes back with its content_type and no text: its text isn’t extracted. proxy is the proxy that served the page: its type and the location your request set. With no location set, a residential or mobile proxy shows the pool near the region you call. challenge is null if nothing got in the way, otherwise it describes the last obstacle:
kind is challenge_page, block_page or page_captcha. captcha is the captcha type as named in Captcha.solve, or null for a challenge page without one. solved is true if the request got past it, by a solve or on its own, and false if it was still there at the end. cost is the total captcha charge for the request as a string, "0" if nothing was charged. receipt is the page’s traffic and captcha solves, with their cost in USD, across every attempt. Browser time is billed on the browser’s session, so billed_seconds and browser_cost are 0; session_uuid names that session, whose receipt is final once the browser stops. receipt is on error responses too, and missing only when the request never reached a browser. A request that couldn’t finish returns HTTP 400 with success: false and a code: Other errors: In the SDKs a failed request raises APIError with the same status_code and code. body has the full response, page included:

Billing

The browser that serves your requests is billed as a browser session: from when it is ready until its last request ends, in 30-second steps, at your plan’s browser-hour rate. The 10 seconds it then waits for your next request aren’t billed. Requests in the same browser, together or one after another, are one session: three 10-second requests sent together are billed as 30 seconds, two back-to-back requests taking 40 seconds as 60. A new_browser: true request is a session of its own. Waiting for a slot costs nothing, and a browser that returned no page isn’t billed for its time. Residential and mobile traffic is billed per GB, datacenter traffic is free, and CAPTCHA solves are billed per solve, also when the site refused the page. On a reserved plan the monthly fee covers browser time; traffic and solves come from the balance. The browser’s session receipt has its time and traffic, and the ledger every charge. Browser slots and request limits per plan; rates are on the pricing page.

When to run your own browser

Start a browser, scrape through it, then stop it. POST /profiles/{internal_uuid}/scrape takes one page per request, and the pages share the browser’s cookies. Pass your own cookies as cookies when you start the browser or on a scrape. The login recipe shows the calls in curl and the SDKs. In the SDKs client.session() stops the browser when the block ends. With plain HTTP, stop it yourself, or it stops after the inactivity timeout. Don’t mix scrape calls and CDP automation in one browser: the scraper takes over the first tab. For more than ten input steps, use the SDK’s human emulation methods. Each response has a receipt for the page. traffic_cost is 0 unless the browser runs on our residential or mobile proxy. Nothing in it is charged on top of the session.