> ## 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.

# 页面监控

> 监控已知 URL，并在页面发生重要变更时接收告警

页面监控用于监控你已经知道的 URL。每次检查都会抓取目标中的每个 URL，将其与上一次保留的快照进行差异比对，并报告该页面是 `same`、`changed`、`new`、`removed` 还是 `error`。对于定价页面、更新日志、文档页面、招聘信息、状态页面，或任何细微变化也很重要的已知 URL，它都是合适的选择。

本页介绍 `scrape` 目标。调度、目标与判定、变更追踪、通知和定价在所有监控类型中都是共通的。请参见 [监控概览](/zh/features/monitoring)。

<div className="firecrawl-cta-box" style={{ background: "transparent" }}>
  <div style={{ display: "flex", alignItems: "center", marginBottom: "12px" }}>
    <Icon icon="sack-dollar" color="#ff4d00" size={22} />
  </div>

  <div className="firecrawl-cta-title">
    <span style={{ color: "#ff4d00" }}>悬赏：5,000 额度奖励</span>
    <span style={{ fontWeight: 400 }}>，征集优质的 /monitor 反馈</span>
  </div>

  <p className="firecrawl-cta-description">
    要符合资格，请通过我们的 Firecrawl Feedback Assistant 完成一次高价值访谈 (例如提供有深度、具体的用例等) 。整个过程只需几分钟，随时都可以停止，对人工和代理都很友好 (只需将链接粘贴到你的 agentic harness 中即可！) 。
  </p>

  <a href={"https://www.firecrawl.dev/interview?study=20260701-monitor-feedback&src=" + (props.src || "docs-monitor")} className="firecrawl-cta-btn-primary firecrawl-cta-btn-inline">
    开始访谈
  </a>
</div>

<div id="create-a-page-monitor">
  ## 创建页面监控
</div>

创建一个使用 `scrape` 目标的监控器，并列出一个或多个明确的 URL：

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

  firecrawl = Firecrawl(
    # 监控端点需要 API 密钥：
    api_key="fc-YOUR-API-KEY",
  )

  monitor = firecrawl.create_monitor(
      name="Hacker News AI monitor",
      schedule={"text": "every 30 minutes", "timezone": "UTC"},
      goal=(
          "Alert when a new Hacker News story related to AI enters the top 10. "
          "Ignore changes to stories that are not about AI. "
          "Do not alert on changes outside the top 10."
      ),
      targets=[
          {
              "type": "scrape",
              "urls": ["https://news.ycombinator.com"],
          }
      ],
      notification={
          "email": {
              "enabled": True,
              "recipients": ["alerts@example.com"],
              "includeDiffs": True,
          }
      },
  )

  print(monitor.id)
  ```

  ```js Node theme={null}
  import Firecrawl from "@mendable/firecrawl-js";

  const firecrawl = new Firecrawl({
    // 监控端点需要 API 密钥：
    apiKey: "fc-YOUR-API-KEY",
  });

  const monitor = await firecrawl.createMonitor({
    name: "Hacker News AI monitor",
    schedule: { text: "every 30 minutes", timezone: "UTC" },
    goal:
      "Alert when a new Hacker News story related to AI enters the top 10. Ignore changes to stories that are not about AI. Do not alert on changes outside the top 10.",
    notification: {
      email: {
        enabled: true,
        recipients: ["alerts@example.com"],
        includeDiffs: true,
      },
    },
    targets: [
      {
        type: "scrape",
        urls: ["https://news.ycombinator.com"],
      },
    ],
  });

  console.log(monitor.id);
  ```

  ```bash cURL theme={null}
  curl -s -X POST "https://api.firecrawl.dev/v2/monitor" \
    -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Hacker News AI monitor",
      "schedule": {
        "text": "every 30 minutes",
        "timezone": "UTC"
      },
      "goal": "Alert when a new Hacker News story related to AI enters the top 10. Ignore changes to stories that are not about AI. Do not alert on changes outside the top 10.",
      "notification": {
        "email": {
          "enabled": true,
          "recipients": ["alerts@example.com"],
          "includeDiffs": true
        }
      },
      "targets": [
        {
          "type": "scrape",
          "urls": ["https://news.ycombinator.com"]
        }
      ]
    }'
  ```
</CodeGroup>

你也可以通过 Firecrawl CLI 创建监控器：

```bash CLI theme={null}
firecrawl monitor create --name "Hacker News AI" \
  --schedule "every 30 minutes" \
  --goal "Alert when a new Hacker News story related to AI enters the top 10. Ignore changes to stories that are not about AI. Do not alert on changes outside the top 10." \
  --page https://news.ycombinator.com
```

<div id="scrape-target">
  ## 抓取目标
</div>

`scrape` 目标需要 `type`，以及一个至少包含一个 URL 的 `urls` 数组。抓取选项会传递到底层的抓取任务。由监控触发的抓取会默认将 `maxAge` 设为 `0`，因此除非你显式设置了其他 `maxAge`，否则每次检查都会执行一次新的抓取。

```json Scrape target theme={null}
{
  "type": "scrape",
  "urls": ["https://example.com/pricing"],
  "scrapeOptions": {
    "formats": ["markdown"],
    "maxAge": 0
  }
}
```

<div id="detecting-field-level-changes">
  ## 检测字段级变更
</div>

默认情况下，页面监控会比较页面 markdown 的差异。若只想在**特定字段**发生变化时触发告警，例如价格、标题、是否有库存的标记，或列表中的条目，请在目标的 `scrapeOptions` 中添加 `changeTracking` 格式。请参见 [变更追踪](/zh/features/monitoring#change-tracking) 了解 JSON 模式和混合模式。

<div id="shared-configuration">
  ## 通用配置
</div>

* [调度](/zh/features/monitoring#schedules): cron 表达式或自然语言频率，最短间隔为 5 分钟。
* [目标与判定](/zh/features/monitoring#goals-and-judging): 仅在出现有意义的变更时发送告警。
* [通知](/zh/features/monitoring#notifications): 通过 webhook 和电子邮件发送。
* [检查结果](/zh/features/monitoring#check-results): 查看每次检查及各页面的差异。
* [定价](/zh/features/monitoring#pricing): 每次检查每个 URL 消耗 1 个额度，另加可选判定。
