页面监控
监控已知 URL,并在页面发生重要变更时接收告警
页面监控用于监控你已经知道的 URL。每次检查都会抓取目标中的每个 URL,将其与上一次保留的快照进行差异比对,并报告该页面是 same、changed、new、removed 还是 error。对于定价页面、更新日志、文档页面、招聘信息、状态页面,或任何细微变化也很重要的已知 URL,它都是合适的选择。
本页介绍 scrape 目标。调度、目标与判定、变更追踪、通知和定价在所有监控类型中都是共通的。请参见 监控概览。
创建一个使用 scrape 目标的监控器,并列出一个或多个明确的 URL:
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": ["[email protected]"],
"includeDiffs": True,
}
},
)
print(monitor.id)你也可以通过 Firecrawl CLI 创建监控器:
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.comscrape 目标需要 type,以及一个至少包含一个 URL 的 urls 数组。抓取选项会传递到底层的抓取任务。由监控触发的抓取会默认将 maxAge 设为 0,因此除非你显式设置了其他 maxAge,否则每次检查都会执行一次新的抓取。
{
"type": "scrape",
"urls": ["https://example.com/pricing"],
"scrapeOptions": {
"formats": ["markdown"],
"maxAge": 0
}
}默认情况下,页面监控会比较页面 markdown 的差异。若只想在特定字段发生变化时触发告警,例如价格、标题、是否有库存的标记,或列表中的条目,请在目标的 scrapeOptions 中添加 changeTracking 格式。请参见 变更追踪 了解 JSON 模式和混合模式。
Was this page helpful?Suggest editsRaise issue