> ## Documentation Index
> Fetch the complete documentation index at: https://help.decodo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 状态、结果与取消

> 跟踪爬取进度、获取已抓取的页面、接收 Webhook 通知，以及提前停止爬取。

爬取以异步方式运行。发起爬取时，响应中会包含 `crawl_id`，以及下方各端点的可直接使用的链接。

<table>
  <colgroup>
    <col width="295" />

    <col width="124" />

    <col width="435" />
  </colgroup>

  <thead>
    <tr>
      <th>端点</th>
      <th>方法</th>
      <th>用途</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`https://data.decodo.com/v1/crawl`</td>
      <td>POST</td>
      <td>发起爬取。</td>
    </tr>

    <tr>
      <td>`https://data.decodo.com/v1/crawl/{crawl_id}/status`</td>
      <td>GET</td>
      <td>爬取状态。</td>
    </tr>

    <tr>
      <td>`https://data.decodo.com/v1/crawl/{crawl_id}`</td>
      <td>GET</td>
      <td>已爬取 URL 的列表，包含每个 URL 的状态和任务 ID。之后您可以使用任务 ID 单独获取每个 URL 的内容。</td>
    </tr>

    <tr>
      <td>`https://data.decodo.com/v1/crawl/{crawl_id}?type=content`</td>
      <td>GET</td>
      <td>内联返回已抓取的页面内容。</td>
    </tr>

    <tr>
      <td>`https://data.decodo.com/v1/crawl/{crawl_id}/cancel`</td>
      <td>POST</td>
      <td>停止爬取并保留已采集的结果。</td>
    </tr>
  </tbody>
</table>

## 查看爬取状态

##### **端点：** `https://data.decodo.com/v1/crawl/{crawl_id}/status`

即爬取响应中的 `crawl_status` 链接。

<CodeGroup>
  ```shellscript cURL theme={null}
  curl --request 'GET' \
    --url 'https://data.decodo.com/v1/crawl/{crawl_id}/status' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer TOKEN VALUE'
  ```
</CodeGroup>

<CodeGroup>
  ```json 响应示例 theme={null}
  {
    "target": "crawl",
    "url": "https://decodo.com/",
    "created_at": "2026-10-08 07:14:45",
    "crawl_id": "{crawl_id}",
    "status": "done",
    "sitemap_status": "skip",
    "output": "markdown",
    "discovered": 2,
    "completed": 2,
    "failed": 0,
    "in_flight": 0,
    "sitemaps": 0,
    "requests": 2
  }
  ```
</CodeGroup>

| 字段 | 说明 |
| :- | :- |
| `status` | 爬取状态：`pending`、`done`、`cancelled`、`truncated`（因 [`max_duration`](/docs/cn/web-data-api-crawl-parameters) 而停止）或 `faulted`（没有任何页面抓取成功）。 |
| `reason` | 爬取提前停止的原因，例如 `max_duration`。仅在爬取状态为 `truncated` 时返回。 |
| `sitemap_status` | 使用了哪些 URL 来源。取值与 [/map](/docs/cn/web-data-api-map-parameters) 中相同。 |
| `output` | 您通过 [`output`](/docs/cn/web-data-api-crawl-parameters) 选择的内容格式。 |
| `discovered` | 目前已发现的 URL 数量。 |
| `completed` | 成功抓取的页面数量。 |
| `failed` | 抓取失败的页面数量。 |
| `in_flight` | 当前正在抓取的页面数量。 |
| `sitemaps` | 已读取的站点地图文件数量。当 `sitemap` 为 `skip`，或网站没有可用的站点地图时，该值为 `0`。 |
| `requests` | 爬取已发出的请求数：成功抓取的页面数加上已读取的站点地图数。失败的页面不计入。 |

## 获取结果

<Note>
  爬取完成后，结果将保存 24 小时。
</Note>

爬取所需时间取决于网站规模及其页面的响应速度，因此没有固定的完成时间。

您可以通过以下两种方式获取爬取结果。

1. 已爬取 URL 列表

##### **端点：** `https://data.decodo.com/v1/crawl/{crawl_id}`

即 `results_tasks` 链接。它会返回本次爬取中的每个 URL 及其各自的状态，方便您查看哪些页面已完成、仍在运行或已失败。

<CodeGroup>
  ```json 响应示例 theme={null}
  {
    "crawl_id": "{crawl_id}",
    "url": [
      {
        "task_id": "7513859416597222401",
        "status": "done",
        "created_at": "2026-10-08 07:14:45",
        "updated_at": "2026-10-08 07:14:51",
        "url": "https://decodo.com/",
        "depth": 0,
        "crawl_status": "https://data.decodo.com/v1/crawl/{crawl_id}/status",
        "results_tasks": "https://data.decodo.com/v1/crawl/{crawl_id}",
        "results_content": "https://data.decodo.com/v1/crawl/{crawl_id}?type=content"
      },
      {
        "task_id": "7513859440462819329",
        "status": "done",
        "created_at": "2026-10-08 07:14:51",
        "updated_at": "2026-10-08 07:14:59",
        "url": "https://decodo.com/proxies/residential-proxies",
        "depth": 1,
        "parent_url": "https://decodo.com/",
        "crawl_status": "https://data.decodo.com/v1/crawl/{crawl_id}/status",
        "results_tasks": "https://data.decodo.com/v1/crawl/{crawl_id}",
        "results_content": "https://data.decodo.com/v1/crawl/{crawl_id}?type=content"
      }
    ]
  }
  ```
</CodeGroup>

`depth` 表示从起始 URL 出发的链接跳转次数，`parent_url` 表示发现该 URL 的页面。之后，您可以通过 `https://data.decodo.com/v1/task/{task_id}/results` 单独获取每个页面的内容。

2. 在响应中内联返回完整内容

##### **端点：** `https://data.decodo.com/v1/crawl/{crawl_id}?type=content`

即 `results_content` 链接。它会按您通过 [`output`](/docs/cn/web-data-api-crawl-parameters) 选择的格式，返回每个页面的抓取内容。结果按每批最多 10 MB 分页返回。当还有更多结果待获取时，响应中会包含 `next` 链接，向该链接发送 `GET` 请求即可获取下一页。`next` 是已附加 `cursor` 值、可直接使用的 URL，无需您自行拼接。最后一页不包含 `next`。

<CodeGroup>
  ```shellscript cURL theme={null}
  curl --request 'GET' --url 'https://data.decodo.com/v1/crawl/{crawl_id}?type=content' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer TOKEN VALUE'
  ```
</CodeGroup>

每个页面包含与已爬取 URL 列表中相同的字段，并额外包含 `content`。`total` 是整个爬取中的页面总数，可能大于本次响应中返回的数量。

抓取失败的页面状态为 `faulted`，并以 `content_error` 代替 `content`。这样既不会阻塞爬取的其余部分，也能让您清楚知道哪些页面需要重试：

```json theme={null}
{
  "status": "faulted",
  "url": "https://example.com/page",
  "depth": 1,
  "content_error": "content could not be fetched from the vendor"
}
```

<CodeGroup>
  ```json 响应示例 theme={null}
  {
    "crawl_id": "{crawl_id}",
    "url": [
      {
        "task_id": "7513859416597222401",
        "status": "done",
        "created_at": "2026-10-08 07:14:45",
        "updated_at": "2026-10-08 07:14:51",
        "url": "https://decodo.com/",
        "depth": 0,
        "content": "[Skip to main content](#main)\n\n[![Decodo Logo](https://images.decodo.com/decodo_logo_83ca8a01e9/decodo_logo_83ca8a01e9.svg)](/)\n\n...",
        "crawl_status": "https://data.decodo.com/v1/crawl/{crawl_id}/status",
        "results_tasks": "https://data.decodo.com/v1/crawl/{crawl_id}",
        "results_content": "https://data.decodo.com/v1/crawl/{crawl_id}?type=content"
      }
    ],
    "total": 2
  }
  ```
</CodeGroup>

当爬取结果过大、无法一次性返回时，响应末尾会附带 `next` 链接：

<CodeGroup>
  ```json 截断的响应 theme={null}
  {
    "crawl_id": "{crawl_id}",
    "url": [
      { "...": "the first batch of pages" }
    ],
    "next": "https://data.decodo.com/v1/crawl/{crawl_id}?cursor=6acf3858fe49e70dea23a874&type=content",
    "total": 40
  }
  ```
</CodeGroup>

请持续请求 `next`，直到返回的响应中不再包含该字段，即表示已是最后一批结果。

## 取消爬取

##### **端点：** `https://data.decodo.com/v1/crawl/{crawl_id}/cancel`

发送 `POST` 请求可提前停止爬取。停止后不会再开始新的页面，正在抓取的页面会继续完成，已采集的所有内容仍可通过结果端点获取。

<CodeGroup>
  ```shellscript cURL theme={null}
  curl --request 'POST' \
    --url 'https://data.decodo.com/v1/crawl/{crawl_id}/cancel' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer TOKEN VALUE'
  ```
</CodeGroup>

响应字段与发起爬取时的响应相同，其中 `status` 为 `cancelled`。

## Webhook

在爬取请求中添加 `callback_url`，所有页面处理完成后，我们会向该地址发送 `POST` 请求，您无需再轮询状态端点。如需确认 Webhook 确实来自 Decodo，可在请求中添加 `passthrough` 值，该值会在 Webhook 载荷中原样返回。

<CodeGroup>
  ```shellscript cURL theme={null}
  curl --request 'POST' \
          --url 'https://data.decodo.com/v1/crawl' \
          --header 'Accept: application/json' \
          --header 'Authorization: Bearer TOKEN VALUE' \
          --header 'Content-Type: application/json' \
          --data '
      {
        "url": "https://decodo.com",
        "callback_url": "https://your.url",
        "passthrough": "your_note"
      }
  '
  ```
</CodeGroup>

Webhook 是一个带有 JSON 正文的 `POST` 请求。它不包含页面内容，请使用 `results` 链接获取内容。

<CodeGroup>
  ```json Webhook 载荷 theme={null}
  {
    "crawl_id": "{crawl_id}",
    "url": "https://decodo.com/",
    "passthrough": "your_note",
    "status": "done",
    "created_at": "2026-10-08 07:14:45",
    "updated_at": "2026-10-08 07:14:59",
    "results": "https://data.decodo.com/v1/crawl/{crawl_id}"
  }
  ```
</CodeGroup>

***

<Columns cols={2}>
  <Card title="支持" href="https://direct.lc.chat/12092754" cta="让我们聊聊！">
    需要帮助或只是想打个招呼？我们的支持团队全天候为您服务。 \
    您也可以随时通过电子邮件 [support@decodo.com](mailto:support@decodo.com) 联系我们。
  </Card>

  <Card title="反馈" href="mailto:feedback@decodo.com" cta="分享反馈">
    找不到您要找的内容？请求一篇文章！ \
    有反馈意见？分享您对我们如何改进的想法。
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.