ページ監視
既知のURLを監視し、ページに意味のある変更があった際に通知を受け取る
ページ監視では、すでに把握しているURLを監視します。各チェックでターゲット内のすべてのURLをスクレイピングし、前回保持されたスナップショットとの差分を取り、そのページが same、changed、new、removed、または error のいずれかであることを報告します。料金ページ、変更履歴、ドキュメントページ、求人情報、ステータスページなど、小さな変更でも重要な既知のURLに適しています。
このページでは scrape ターゲットを扱います。スケジューリング、ゴールと判定、変更追跡、通知、価格設定はすべてのモニタータイプで共通です。Monitoring overview を参照してください。
1 つ以上の URL を明示的に指定する scrape ターゲットを持つモニターを作成します。
from firecrawl import Firecrawl
firecrawl = Firecrawl(
# MonitorのエンドポイントにはAPI keyが必要です:
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 と、少なくとも 1 つの URL を含む urls 配列が必要です。スクレイピングのオプションは、内部のスクレイピングジョブにそのまま渡されます。モニター によって実行されるスクレイピングでは、maxAge のデフォルト値が 0 のため、明示的に別の maxAge を設定しない限り、チェックごとに新しいスクレイピングが実行されます。
{
"type": "scrape",
"urls": ["https://example.com/pricing"],
"scrapeOptions": {
"formats": ["markdown"],
"maxAge": 0
}
}デフォルトでは、ページモニターはページのMarkdownの差分を比較します。価格、見出し、在庫フラグ、リスト内の項目など、特定のフィールドが変更されたときだけ通知するには、ターゲットのscrapeOptionsにchangeTrackingフォーマットを追加します。JSONモードとMixedモードについては、変更追跡を参照してください。