firecrawl-instruct

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

firecrawl instruct

firecrawl instruct

Interact with scraped pages in a live browser session. Scrape a page first, then use natural language prompts or code to click, fill forms, navigate, and extract data.
在实时浏览器会话中与已爬取的页面进行交互。首先爬取页面,随后使用自然语言提示或代码执行点击、填写表单、导航、提取数据等操作。

When to use

适用场景

  • Content requires interaction: clicks, form fills, pagination, login
  • scrape
    failed because content is behind JavaScript interaction
  • You need to navigate a multi-step flow
  • Last resort in the workflow escalation pattern: search → scrape → map → crawl → instruct
  • Never use instruct for web searches — use
    search
    instead
  • 内容需要交互才能获取:点击操作、表单填写、翻页、登录
  • scrape
    命令执行失败,因为内容需要JavaScript交互才能加载
  • 需要导航多步骤流程
  • 工作流升级模式的最终方案:搜索 → 爬取 → 映射 → 抓取 → instruct
  • 绝对不要使用instruct进行网页搜索 —— 请改用
    search
    命令

Quick start

快速开始

bash
undefined
bash
undefined

1. Scrape a page (scrape ID is saved automatically)

1. 爬取页面(爬取ID会自动保存)

firecrawl scrape "<url>"
firecrawl scrape "<url>"

2. Interact with the page using natural language

2. 使用自然语言与页面交互

firecrawl interact --prompt "Click the login button" firecrawl interact --prompt "Fill in the email field with test@example.com" firecrawl interact --prompt "Extract the pricing table"
firecrawl interact --prompt "Click the login button" firecrawl interact --prompt "Fill in the email field with test@example.com" firecrawl interact --prompt "Extract the pricing table"

3. Or use code for precise control

3. 或使用代码实现精准控制

firecrawl interact --code "agent-browser click @e5" --language bash firecrawl interact --code "agent-browser snapshot -i" --language bash
firecrawl interact --code "agent-browser click @e5" --language bash firecrawl interact --code "agent-browser snapshot -i" --language bash

4. Stop the session when done

4. 操作完成后停止会话

firecrawl interact stop
undefined
firecrawl interact stop
undefined

Options

选项

OptionDescription
--prompt <text>
Natural language instruction (use this OR --code)
--code <code>
Code to execute in the browser session
--language <lang>
Language for code: bash, python, node
--timeout <seconds>
Execution timeout (default: 30, max: 300)
--scrape-id <id>
Target a specific scrape (default: last scrape)
-o, --output <path>
Output file path
选项说明
--prompt <text>
自然语言指令(与--code二选一使用)
--code <code>
要在浏览器会话中执行的代码
--language <lang>
代码语言:bash、python、node
--timeout <seconds>
执行超时时间(默认:30,最大值:300)
--scrape-id <id>
目标指定的爬取任务(默认:最近一次爬取)
-o, --output <path>
输出文件路径

Profiles

配置文件

Use
--profile
on the scrape to persist browser state (cookies, localStorage) across scrapes:
bash
undefined
在爬取时使用
--profile
参数可持久化浏览器状态(cookies、localStorage),在多次爬取间复用:
bash
undefined

Session 1: Login and save state

会话1:登录并保存状态

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/login" --profile my-app firecrawl interact --prompt "Fill in email with user@example.com and click login"

Session 2: Come back authenticated

会话2:直接以已登录状态访问

firecrawl scrape "https://app.example.com/dashboard" --profile my-app firecrawl interact --prompt "Extract the dashboard data"

Read-only reconnect (no writes to profile state):

```bash
firecrawl scrape "https://app.example.com" --profile my-app --no-save-changes
firecrawl scrape "https://app.example.com/dashboard" --profile my-app firecrawl interact --prompt "Extract the dashboard data"

只读重连(不写入配置文件状态):

```bash
firecrawl scrape "https://app.example.com" --profile my-app --no-save-changes

Tips

使用提示

  • Always scrape first —
    interact
    requires a scrape ID from a previous
    firecrawl scrape
    call
  • The scrape ID is saved automatically, so you don't need
    --scrape-id
    for subsequent interact calls
  • Use
    firecrawl interact stop
    to free resources when done
  • For parallel work, scrape multiple pages and interact with each using
    --scrape-id
  • 始终先执行爬取操作 ——
    interact
    命令需要使用之前
    firecrawl scrape
    调用生成的爬取ID
  • 爬取ID会自动保存,因此后续的interact调用不需要指定
    --scrape-id
  • 操作完成后使用
    firecrawl interact stop
    释放资源
  • 如果需要并行操作,可以爬取多个页面,通过
    --scrape-id
    分别与每个页面交互

See also

另请参阅

  • firecrawl-scrape — try scrape first, escalate to instruct only when needed
  • firecrawl-search — for web searches (never use instruct for searching)
  • firecrawl-agent — AI-powered extraction (less manual control)
  • firecrawl-scrape —— 先尝试使用scrape,仅当必要时再升级使用instruct
  • firecrawl-search —— 用于网页搜索(绝对不要使用instruct进行搜索)
  • firecrawl-agent —— AI驱动的提取(手动控制程度更低)