Actions 字段
actions 允许你在抓取之前执行浏览器动作(点击、输入、滚动、执行 JS 等),再获取最终内容。
限制与注意事项
Section titled “限制与注意事项”- actions 按顺序执行
- 单次请求最多 50 个 action
- 所有
wait(含waitFor)累计等待时间不应超过 60s - PDF 不支持 actions:如果 URL 实际解析为 PDF,请不要使用 actions,否则请求会失败
action 类型与字段
Section titled “action 类型与字段”wait(等待)
Section titled “wait(等待)”等待固定时长或等待某元素可见(二选一)。
{ type: 'wait', milliseconds: 1000 }{ type: 'wait', selector: '#content' }| 字段 | 类型 | 说明 |
|---|---|---|
milliseconds | number | 固定等待 |
selector | string | 等待元素可见(超时 30s) |
click(点击)
Section titled “click(点击)”{ type: 'click', selector: '#accept' }{ type: 'click', selector: '.expand', all: true }| 字段 | 类型 | 说明 |
|---|---|---|
selector | string | CSS 选择器 |
all | boolean | 是否点击所有匹配元素 |
write(输入)
Section titled “write(输入)”{ type: 'click', selector: '#q' }{ type: 'write', text: 'firecrawl' }| 字段 | 类型 | 说明 |
|---|---|---|
text | string | 输入的文本;通常需要先 click 让输入框获得焦点 |
press(按键)
Section titled “press(按键)”{ type: 'press', key: 'Enter' }| 字段 | 类型 | 说明 |
|---|---|---|
key | string | 键名(如 Enter/Tab/Escape) |
scroll(滚动)
Section titled “scroll(滚动)”{ type: 'scroll', direction: 'down' }{ type: 'scroll', selector: '.list' }| 字段 | 类型 | 说明 |
|---|---|---|
direction | "up" | "down" | 方向,默认 down |
selector | string | 滚动指定容器 |
screenshot(截图)
Section titled “screenshot(截图)”{ type: 'screenshot', fullPage: true, quality: 80 }| 字段 | 类型 | 说明 |
|---|---|---|
fullPage | boolean | 整页 |
quality | number | 质量参数 |
viewport | object | { width, height } |
scrape(抓取当前 HTML)
Section titled “scrape(抓取当前 HTML)”{ type: 'scrape' }此 action 会把当前页面 HTML 片段写入响应的 data.actions.scrapes。
executeJavascript(执行 JS)
Section titled “executeJavascript(执行 JS)”{ type: 'executeJavascript', script: "document.title" }返回值会出现在 data.actions.javascriptReturns。
pdf(生成 PDF)
Section titled “pdf(生成 PDF)”{ type: 'pdf', format: 'A4', landscape: false, scale: 1 }| 字段 | 类型 | 说明 |
|---|---|---|
format | string | 例如 A0-A6 / Letter / Legal 等 |
landscape | boolean | 横向 |
scale | number | 缩放 |