# web.crawl

Crawl a public website from a start page and read its pages as clean Markdown, obeying robots.txt.

Website to Markdown, one of the Web scrapers.

| | |
| --- | --- |
| Id | `web.crawl` |
| Version | 1 |
| Billed per | record — 1 unit for each record of a charged run |
| Runs | in the background; use wait or poll |

Start it with `POST /v1/scrapers/web.crawl/runs`. How runs work is in [Running a scraper](https://docs.enrichednow.com/running-a-scraper.md); what a run costs is in [Usage and units](https://docs.enrichednow.com/usage-and-units.md).

## Inputs

The fields of `input`. A field that is not listed here is refused.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `main_content_only` | boolean | no | Write the page's own content only: no navigation, page header or footer, sidebars or cookie banners. False writes the whole page body. Default: `true`. |
| `include_links` | boolean | no | Write links as [text](address); false keeps their text only. Default: `true`. |
| `include_images` | boolean | no | Write images as ![alt](address); false keeps their alt text only. Default: `false`. |
| `url` | string | yes | The start page: http or https, on a public host name. Limit: at most 2048 characters. |
| `max_pages` | integer | no | Stop after this many pages (records). Limit: 1 to 100. Default: `10`. |
| `max_depth` | integer | no | How many links away from the start page a page may be; 0 reads the start page only. Pages from the sitemap count as 1. Limit: 0 to 10. Default: `3`. |
| `include_paths` | array of string | no | Read only pages whose path starts with one of these (`/docs/`), or matches one with `*` (`/blog/*/comments`). The start page is always read. |
| `exclude_paths` | array of string | no | Never read pages whose path starts with or matches one of these. |
| `follow` | "links" \| "next_page" | no | `links`: every link on the site's pages, and its sitemap. `next_page`: only each page's link to the next page of its list (`next_url`: `rel=next`, or a link labelled Next, › or »), one page after the other: for a directory, search results or an archive split over pages. `max_depth` does not apply to `next_page`. Default: `"links"`. |
| `same_site_only` | true | no | Only the start page's site is crawled; this cannot be turned off. Default: `true`. |
| `max_seconds` | integer | no | The time budget of the whole crawl, in seconds. Limit: 10 to 900. Default: `300`. |

- Only the start page's site is crawled, and its `robots.txt` is obeyed: it is read first, a crawl of a start page it forbids ends `unsupported` with `disallowed_by_robots`, and a `robots.txt` that cannot be read ends the run `failed` with `robots_unreachable`.
- Billed per record: a charged run costs 1 unit for each page it returns. `max_pages` bounds that.
- No JavaScript is run. A start page that builds its content in the browser ends the run `unsupported` with `render_required`; such a page met later is passed over.
- A crawl that could not read every page ends `partial` — `pages_failed` when a page failed, `time_budget_exceeded` when `max_seconds` ran out — with the pages it read, and is charged for those.
- `max_seconds` can be set up to 900, but a run has 5 minutes: a crawl still going then ends `partial` with `deadline_exceeded`.
- The record's `depth` is how many links the page is from the start page; a page found in the sitemap counts as 1.

## Record fields

Every record of a run has these fields. A value that is not known is `null` — never an empty string and never `0`.

| Field | Type | Notes |
| --- | --- | --- |
| `url` | string | The address that was asked for. |
| `final_url` | string | The address that answered, after redirects. |
| `status` | integer | The HTTP status of the answer. |
| `content_type` | string or null | The media type of the answer, e.g. text/html. |
| `title` | string or null | The page's title. |
| `description` | string or null | The page's meta description. |
| `language` | string or null | The language the page declares (e.g. en, de-CH); null when it declares none. |
| `canonical_url` | string or null | The canonical address the page names for itself. |
| `markdown` | string | The page's content as Markdown. |
| `text_length` | integer | Characters of plain text in the content that was written. |
| `word_count` | integer | Words of plain text in the content that was written. |
| `links` | array of object | The links on the whole page, once each (the first 2000). |
| `links[].url` | string | The link's address, absolute, without its fragment. |
| `links[].text` | string or null | The link's text; null when it has none. |
| `links[].same_site` | boolean | True when the link stays on the page's host (`www.` aside). |
| `next_url` | string or null | The address of the next page of the list this page shows (a directory, search results, an archive), when the page links to one on its own site: `rel=next`, or a link labelled Next, › or ». Null otherwise. web.crawl with `follow: next_page` reads these pages one after the other. |
| `metadata` | object | What the page declares about itself in structured form: its Open Graph properties and its JSON-LD objects. Both are empty when it declares none. |
| `metadata.open_graph` | object of string values | The page's Open Graph properties (og:*, article:*). |
| `metadata.json_ld` | array of object | The page's JSON-LD objects, as written. |
| `truncated` | boolean | True when the page was longer than 5000000 bytes and was cut there. Default: `false`. |
| `depth` | integer or null | web.crawl only: links between the start page and this one. |
| `fetched_at` | string (date-time) | When the page was fetched, in UTC. |

## Example request

It starts a run with this scraper's example input and waits up to 60 seconds for it. The key is read from `ENRICHEDNOW_API_KEY`.

```bash
curl -X POST "https://api.enrichednow.com/v1/scrapers/web.crawl/runs?wait=60" \
  -H "Authorization: Bearer $ENRICHEDNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":{"url":"https://docs.widgetlib.org/en/stable/index.html","max_pages":10}}'
```

## Example response

The run, once it has ended. A run that has not ended within `wait` comes back with `202` and the status `queued` or `running`.

```json
{
  "id": "run_841742f37553189ff9c27ba1",
  "scraper_id": "web.crawl",
  "scraper_version": 1,
  "status": "ok",
  "reason": null,
  "input": {
    "url": "https://docs.widgetlib.org/en/stable/index.html",
    "max_pages": 10
  },
  "record_count": 1,
  "units": 1,
  "units_per_request": null,
  "units_per_record": 1,
  "units_per_page": null,
  "diagnostics": {
    "requests": 1,
    "bytes": 259214,
    "wall_ms": 885,
    "facts": {}
  },
  "created_at": "2026-11-16T22:37:50.170950Z",
  "started_at": "2026-11-16T22:37:50.178331Z",
  "finished_at": "2026-11-16T22:37:51.066313Z"
}
```

Its records, from `GET /v1/runs/{id}/records`. The record was read by this scraper's own parser from a page built by hand for its tests, because no real page could be recorded: its fields and shapes are the scraper's, its values are invented.

```json
{
  "records": [
    {
      "url": "https://docs.widgetlib.org/en/stable/quickstart.html",
      "final_url": "https://docs.widgetlib.org/en/stable/quickstart.html",
      "status": 200,
      "content_type": "text/html",
      "title": "Quickstart — widgetlib 2.4 documentation",
      "description": null,
      "language": "en",
      "canonical_url": null,
      "markdown": "# Quickstart\n\nInstall `widgetlib` with pip:\n\n```console\n$ pip install widgetlib\n```\n\n## Your first widget\n\n```python\nfrom widgetlib import Widget\n\nw = Widget(size=3)\nprint(w.render())  # ``<widget size=3>``\n```\n\nNote\n\nSee [the API … [truncated]",
      "text_length": 299,
      "word_count": 46,
      "links": [
        {
          "url": "https://docs.widgetlib.org/en/stable/api.html",
          "text": "API reference",
          "same_site": true
        },
        {
          "url": "https://docs.widgetlib.org/en/stable/index.html",
          "text": "Home",
          "same_site": true
        }
      ],
      "metadata": {
        "open_graph": {},
        "json_ld": []
      },
      "truncated": false,
      "depth": 1,
      "fetched_at": "2026-11-19T18:07:42.164737Z"
    }
  ],
  "next_cursor": null
}
```

What was done to the record for this page, and nothing else — the API returns every value whole. A text that was cut ends with `… [truncated]`.

- Shortened: `markdown`: 466 characters, the first 230 shown.
- Shortened: `links`: 3 items, the first 2 shown.

A run does not always end `ok`. [Results and statuses](https://docs.enrichednow.com/results-and-statuses.md#reason-codes) lists every status and the reasons every scraper shares; [the reasons of the Web scrapers](https://docs.enrichednow.com/results-and-statuses.md#web) are in their own section there.
