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

# PII 脱敏

> 对抓取和解析结果中的个人身份信息进行脱敏

在你将返回的 markdown 发送到下游的代理、日志、向量存储或分析管道之前，PII 脱敏会先替换其中的个人身份信息。

<div id="how-it-works">
  ## 工作原理
</div>

在 抓取 请求中设置 `redactPII: true`。Firecrawl 会对生成的 markdown 进行脱敏，并在 `markdown` 中返回脱敏后的版本。你无需传递 `formats`；markdown 是默认输出。

<CodeGroup>
  ```python Python theme={null}
  from firecrawl import Firecrawl

  firecrawl = Firecrawl(
    # 无需 API 密钥即可开始使用 — 添加后可提升限流额度：
    # api_key="fc-YOUR_API_KEY",
  )

  doc = firecrawl.scrape(
      "https://example.com/contact",
      redact_pii=True,
  )

  print(doc.markdown)
  ```

  ```javascript JavaScript theme={null}
  import { Firecrawl } from 'firecrawl';

  const firecrawl = new Firecrawl({
    // 无需 API 密钥即可开始使用 — 添加后可提高限流上限：
    // apiKey: "fc-YOUR_API_KEY",
  });

  const doc = await firecrawl.scrape('https://example.com/contact', {
    redactPII: true,
  });

  console.log(doc.markdown);
  ```

  ```bash cURL theme={null}
  # 无需 API 密钥即可开始使用 — 添加 -H "Authorization: Bearer fc-YOUR_API_KEY" 以获得更高的限流配额：
  curl -X POST https://api.firecrawl.dev/v2/scrape \
    -H 'Content-Type: application/json' \
    -d '{
      "url": "https://example.com/contact",
      "redactPII": true
    }'
  ```

  ```bash CLI theme={null}
  # 返回已脱敏个人身份信息的 markdown。
  firecrawl https://example.com/contact --redact-pii
  ```
</CodeGroup>

<div id="redaction-options">
  ## 脱敏选项
</div>

对于大多数请求，请使用 `redactPII: true`。如需调整脱敏设置，请传入一个选项对象：

```json theme={null}
{
  "redactPII": {
    "mode": "accurate",
    "entities": ["EMAIL", "PHONE", "SECRET"],
    "replaceStyle": "tag"
  }
}
```

| 选项             | 值                                                             | 默认值        | 描述                                                                |
| -------------- | ------------------------------------------------------------- | ---------- | ----------------------------------------------------------------- |
| `mode`         | `accurate`, `aggressive`, `fast`                              | `accurate` | 脱敏策略。`accurate` 仅走模型路径，`aggressive` 会通过额外启发式提高召回率，`fast` 则跳过模型调用。 |
| `entities`     | `PERSON`, `EMAIL`, `PHONE`, `LOCATION`, `FINANCIAL`, `SECRET` | 所有实体       | 将脱敏限制在特定实体类别内。                                                    |
| `replaceStyle` | `tag`, `mask`, `remove`                                       | `tag`      | 将文本片段替换为 `<EMAIL>` 这类标签、用 `*` 掩盖，或直接删除这些字符。                       |

<Note>
  Firecrawl CLI 和 MCP server 仅提供简单的布尔型脱敏。高级选项可通过暴露完整 `redactPII` 选项对象的 API 和 SDKs 使用。
</Note>

<div id="response">
  ## 响应
</div>

脱敏成功后，`markdown` 中会包含脱敏后的内容：

```json theme={null}
{
  "success": true,
  "data": {
    "markdown": "Contact us at <EMAIL> or <PHONE>.",
    "metadata": {
      "sourceURL": "https://example.com/contact"
    }
  }
}
```

如需在命令行中查看，可将 markdown 通过管道传给你常用的渲染器：

```bash cURL theme={null}
curl -X POST https://api.firecrawl.dev/v2/scrape \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
    "url": "https://dlptest.com/sample-data.pdf",
    "redactPII": true
  }' | jq -r ".data.markdown" | glow
```

<div id="billing">
  ## 计费
</div>

PII 脱敏的成本为每页 5 个额度：1 个基础抓取额度，外加 4 个脱敏额度。

对于已解析的 PDF，每增加一页 PDF，仍会产生常规的 PDF 解析额度，并且还会额外收取脱敏费用。

<div id="availability">
  ## 可用性
</div>

凡是 Firecrawl 支持传入抓取选项的地方，都支持 PII 脱敏：

* **抓取** - 在 `/v2/scrape` 上设置 `redactPII`。
* **爬取、批量抓取和搜索** - 在 `scrapeOptions` 中传入 `redactPII`。
* **解析** - 在 multipart 请求的 `options` JSON 中传入 `redactPII`。
* **SDKs** - Python 使用 `redact_pii`；JavaScript 和其他 SDKs 使用 `redactPII` 或其原生选项命名风格。
* **CLI** - 向 `firecrawl scrape` 传入 `--redact-pii`。
* **MCP server** - 在 `firecrawl_scrape` 工具参数中加入 `"redactPII": true`，以启用简单的布尔值脱敏。

> 你是需要 Firecrawl API 密钥的 AI 代理吗？请参见 [firecrawl.dev/agent-onboarding/SKILL.md](https://www.firecrawl.dev/agent-onboarding/SKILL.md) 了解自动化引导说明。
