SuperAPI AI 工具集

firecrawl-interact

数据与分析

查看项目

更新于 10-15 08:33

技能介绍

firecrawl-interact 是 Firecrawl CLI 提供的页面交互命令,用于在已抓取的页面上驱动一个实时浏览器会话。它适用于内容需要交互才能获取,或普通抓取失败的情况。

用途 当目标页面需要点击、填写表单、登录、翻页或无限滚动才能呈现内容时,可以先抓取页面,再通过自然语言提示或代码对页面进行操作并提取数据。需要注意的是,interact 针对的是某个具体页面;如果要做网络搜索,应使用 search。

主要能力

  • 在实时浏览器会话中点击、填写表单、导航和提取数据。
  • 支持自然语言提示,例如点击登录按钮、填写邮箱字段、提取定价表。
  • 支持通过代码进行精确控制,例如使用 agent-browser click @e5 或 agent-browser snapshot -i。
  • 支持 --profile 在多次抓取之间持久化浏览器状态(cookies、localStorage),实现登录后再次访问已认证页面。
  • 支持只读重连,使用 --no-save-changes 不写入 profile 状态。

使用方式

  1. 先抓取页面,scrape ID 会自动保存:firecrawl scrape "<url>"。
  2. 使用位置参数提示进行交互:firecrawl interact "Click the login button"、firecrawl interact "Fill in the email field with test@example.com"、firecrawl interact "Extract the pricing table"。
  3. 如果第一个参数是 UUID,会被自动识别为 scrape ID:firecrawl interact "<scrape-id>" "Extract the pricing table"。
  4. 使用代码进行精确控制:firecrawl interact --code "agent-browser click @e5" --bash、firecrawl interact --code "agent-browser snapshot -i" --bash。
  5. 完成后停止会话:firecrawl interact stop。
  6. 查看完整选项列表:firecrawl interact --help。

Profiles 用法 在 scrape 时使用 --profile 可跨抓取持久化浏览器状态。示例:先抓取登录页并保存状态 firecrawl scrape "https://app.example.com/login" --profile my-app,再交互填写邮箱并点击登录 firecrawl interact --prompt "Fill in email with user@example.com and click login";之后再次抓取仪表盘页面 firecrawl scrape "https://app.example.com/dashboard" --profile my-app,并交互提取数据 firecrawl interact --prompt "Extract the dashboard data"。只读重连可使用 firecrawl scrape "https://app.example.com" --profile my-app --no-save-changes。

适用场景

  • 需要登录后才能访问的页面。
  • 需要点击、填表、翻页或无限滚动才能加载的内容。
  • 普通抓取失败、需要交互才能获取数据的页面。
  • 需要并行处理多个页面时,可抓取多个页面并分别用 --scrape-id 进行交互。

限制与注意事项

  • 必须先抓取:interact 需要来自之前 firecrawl scrape 调用的 scrape ID。
  • scrape ID 会自动保存,因此后续 interact 调用可省略 --scrape-id。
  • 保存的会话可能在大约 10 分钟后过期;如果 CLI 提示会话已过期,需要重新抓取。
  • 完成后应使用 firecrawl interact stop 释放资源。
  • 完成标准是:请求的内容或操作结果已被捕获,并且会话已通过 firecrawl interact stop 停止。

相关命令

  • firecrawl-scrape:优先尝试抓取,仅在需要时升级到 interact。
  • firecrawl-search:用于网络搜索。
  • firecrawl-agent:AI 驱动的提取,手动控制较少。
  • firecrawl-build-interact:将 interact 构建到应用中,而不是在此处运行。