---
title: "Scrape"
description: "What scrape() hands back from each provider. HTML from some and markdown from others and an error from one"
canonical_url: "https://browsers.agntn.dev/guide/scrape"
---
# Scrape

> What scrape() hands back from each provider. HTML from some and markdown from others and an error from one

## One call, a different answer from each

Same URL, same tool, same minute. This is `browsers_scrape` on `https://example.com` through every provider, recorded with real keys and kept exactly as it came back.

<scrape-walk>



</scrape-walk>

Look at the sizes. Kernel and Browserless hand back the raw HTML, stylesheet and all, for a page with a few sentences on it. Steel, Browserbase and Hyperbrowser answer in markdown. Playwright gives you `innerText`. Cloudflare gives markdown with a front matter block on top. Anchor says no.

None of that is a bug in this package. It's what the vendors return, and hiding it behind a fake "normalized" text would be worse. What the package does promise is the shape: a `ScrapeResult` with `url` and whichever of `html`, `markdown`, `text`, `title` and `statusCode` the vendor filled.

## In TypeScript

```ts
import { create } from "@agntn/browsers";

const provider = await create("cloudflare");
const page = await provider.scrape("https://example.com", {
  formats: ["markdown", "html"],
  waitFor: "main",
});

page.markdown;
page.html;
page.statusCode;
```

The options are `formats`, `waitFor` (a CSS selector), `waitForNetworkIdle`, `screenshot`, `links`, `maxChars`, `timeout`, `script`, `headers` and `signal`. Vendors don't honour every option, so treat them as requests. `waitFor` is an exception, more on that below.

Every built-in provider honours `signal`. Abort it and the scrape ends, and any temporary session it opened gets released.

Cloudflare is the generous one here. Ask for `html` and `markdown` together, or add `screenshot: true`. Add `links: true` to get `page.links` alongside a page format. That's text and destinations from one render.

Want links without asking? Playwright and Attach include them on every scrape. Cloudflare waits for your request. It's worth asking.

## Waiting for a page that loads late

Some pages arrive empty and fill themselves in a few seconds later. Read them too early and you get the skeleton. `waitFor` holds the read until its selector shows up.

Kernel, Browserless, Cloudflare, Playwright, Lightpanda and Attach wait, and the flag is `scrapeWaitFor`. Steel, Browserbase and Hyperbrowser have nothing to wait with. So they refuse before any request goes out:

```text
steel cannot wait for a selector before a scrape. Use kernel, browserless, cloudflare, playwright or lightpanda, or drop waitFor.
```

Rude? A little. But the old answer was an empty page that looked like a finished one. Leave the provider out and the first configured one that can wait gets the job.

## Session or no session

`capabilities().statelessScrape` says whether a provider scrapes without a session. Kernel is the one that doesn't. `provider.scrape(url)` there wants a session as its third argument:

```ts
const kernel = await create("kernel");
const session = await kernel.createSession();
try {
  const page = await kernel.scrape("https://example.com", {}, session);
} finally {
  await kernel.releaseSession(session.id);
}
```

The CLI and the agent tools do exactly this for you, `finally` included. Forget the release in your own code and the vendor keeps billing the browser until its own timeout. Don't.

## The agent's version

`browsers_scrape` asks for markdown and hands the model text first, then markdown, then HTML, whichever exists. It stops at 20 000 characters unless you pass `maxChars`, up to 200 000, and says how much it cut:

```text
[truncated 4200 of 24200 characters]
```

So a model never gets a silent half page. It gets told.

## Kitesurf

Cloudflare's Browser Run has a second engine, Kitesurf. Opt in with `create("cloudflare", { browser: "kitesurf" })`, `--browser kitesurf` in the CLI, or `browser: "kitesurf"` on a tool. Leave it out and Cloudflare stays on Chromium.


## Sitemap

See the full [sitemap](https://browsers.agntn.dev/sitemap.md) for all pages.
