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

# 使用 Fetch API 按 URL 抓取任意网页

> 使用 Bright Data Fetch API 爬虫按 URL 采集任意公开网页，以 Markdown、纯文本、原始 HTML 或 JSON-LD 格式返回，并可通过 country 参数指定国家。发送 POST /datasets/v3/scrape 获取结果。

Fetch API（原 Crawl API）是 Web Unlocker API 在 Scraper API 中的对应产品。发送任意公开 URL，即可在一条记录中获取该网页的 Markdown、纯文本、原始 HTML 和 JSON-LD。

## 查询参数

<ParamField query="dataset_id" type="string" default="gd_m6gjtfmeh43we6cqc" required>
  用于此请求的数据集 ID。

  <Warning>
    必须设置为 `gd_m6gjtfmeh43we6cqc` 才能采集 **Fetch API - 按 URL 采集** 数据。
  </Warning>
</ParamField>

<ParamField query="notify" type="boolean" default={false}>
  请求完成时是否发送通知。
</ParamField>

<ParamField query="include_errors" type="boolean" default={true}>
  是否在响应中包含错误。
</ParamField>

<ParamField query="custom_output_fields" type="string">
  仅返回列出的输出字段，字段之间用竖线（`|`）分隔。例如，`url|markdown` 仅返回 URL 和网页的 Markdown 版本。
</ParamField>

## 请求体

<ParamField body="input" type="object[]" required>
  输入对象数组。

  <Expandable title="属性">
    <ParamField body="url" type="string" required>
      要获取的网页 URL。接受任意公开域名。
    </ParamField>

    <ParamField body="country" type="string">
      获取网页时使用的两位国家代码，例如 `us` 或 `de`。
    </ParamField>
  </Expandable>

  #### 示例

  ```json wrap theme={null}
  {
    "input": [
      {"url": "https://example.com"},
      {"url": "https://example.com/1", "country": "us"}
    ]
  }
  ```
</ParamField>

## 输出字段

每条记录包含以下字段：

| 字段 | 类型 | 说明 |
| - | - | - |
| `url` | url | 输入的 URL |
| `final_url` | url | 重定向后的 URL |
| `page_title` | text | 网页标题 |
| `country` | country | 获取网页时使用的国家 |
| `markdown` | Markdown | 以 Markdown 格式呈现的网页内容，保留标题、列表和链接 |
| `html2text` | text | 去除所有 HTML 标签和格式后的网页文本 |
| `page_html` | HTML | 完整的 HTML 源代码，包括标签、脚本和样式 |
| `ld_json` | JSON | 网页中的 JSON-LD 结构化元数据，例如 schema.org 数据 |

如只需要部分字段，请设置 `custom_output_fields`，例如 `custom_output_fields=url|markdown`。

<ResponseExample>
  ```json 200 theme={null}
  [
    {
      "url": "https://example.com",
      "final_url": "https://example.com/",
      "page_title": "Example Domain",
      "country": "us",
      "markdown": "# Example Domain\n\nThis domain is for use in illustrative examples in documents.",
      "html2text": "Example Domain\n\nThis domain is for use in illustrative examples in documents.",
      "page_html": "<!doctype html><html><head><title>Example Domain</title></head><body><div><h1>Example Domain</h1><p>This domain is for use in illustrative examples in documents.</p></div></body></html>",
      "ld_json": null
    }
  ]
  ```
</ResponseExample>
