mcpField
S
scrapfly-cli

scrapfly-cli

github.com/scrapfly数据与数据库5213 次安装2 周前更新
代码仓库

关于 scrapfly-cli

scrapfly-cli 是 Scrapfly 的命令行工具,覆盖网页抓取、截图、提取、爬取和浏览器操作,适用于开发者和 AI Agent。它默认输出 JSON,便于管道调用,并提供由模型选择操作的浏览器 Agent 模式。

主要功能

  1. 01抓取网页并提取内容
  2. 02截图并执行递归爬取
  3. 03控制一次性或持久 CDP 浏览器会话
  4. 04以 LLM Agent 模式执行浏览器任务
  5. 05安排定期任务并配置告警
  6. 06为 LLM 管道输出结构化 JSON

适用场景

  1. 01通过命令行获取和处理网页
  2. 02在持久会话中自动化浏览器操作
  3. 03让 LLM Agent 浏览和检查网站
  4. 04定期爬取并通过 Webhook 发送结果

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/scrapfly/skills --skill scrapfly-cli

安装后在 Claude Code 中输入/scrapfly-cli确认已加载。

详细介绍

Scrapfly:网页抓取、渲染与浏览器自动化

Scrapfly 通过五种产品让 AI Agent 和应用访问 Web:抓取、截图、AI 提取、递归爬取,以及可通过 CDP 直接控制、通过持久会话守护进程控制,或交由大模型 Agent 使用的远程浏览器。

这个 CLI scrapfly 是覆盖全部五种产品的统一入口,另提供类似 Playwright-MCP 的 Agent 模式。它默认使用 JSON,因此大模型调用方可以直接通过管道传递数据。

安装

可在发布页面获取预构建的二进制文件(macOS 通用版、Linux amd64/arm64、Windows amd64)。也可从源代码构建:

go install github.com/scrapfly/scrapfly-cli/cmd/scrapfly@latest

六种使用方式

方式 A(获取内容): scrapfly scrape <url>——默认方式。涵盖 SDK 中 ScrapeConfig 的所有字段:

  • 渲染与导航:--render-js、--wait-for-selector、--rendering-wait、 --rendering-stage、--auto-scroll、--js-file FILE、--js-scenario-file FILE
  • 代理池与反机器人:--unblocker-ultra(别名 --asp)、--unblocker、 --proxy-pool basic|unblocker|unblocker_ultra|auto、--cost-budget N、 --country、--geolocation
  • 格式与提取:--format markdown|clean_html|text|raw + --format-option; --extraction-prompt、--extraction-model、--extraction-template、 --extraction-template-file FILE(临时内联模板)
  • 请求格式:--method、--header k=v、--cookie n=v、--body、 --body-file、--data-file FILE(以 JSON 映射表示的结构化请求体)、--lang、 --os、--browser-brand
  • 会话与缓存:--session、--session-sticky-proxy、--cache、 --cache-ttl N、--cache-clear、--retry=true|false
  • 抓取时截图:--screenshot(整页快捷选项)、 --screenshot-named name=selector(可重复指定)、--screenshot-flag FLAG
  • 可观测性:--debug、--ssl、--dns、--correlation-id、--tag、 --webhook NAME、--timing
  • 批处理:多个位置参数 URL,或使用 --from-file PATH|- + --concurrency (标准输出为 ndjson)
  • 适合管道处理:--proxified 以流的形式输出上游原始响应体,不附带 JSON 封装

网站封锁请求时,应使用 --unblocker-ultra(proxy_pool=unblocker_ultra):它不会被拒绝,费用与 --unblocker 相同;但如果目标网站或反机器人防护本身有额外费用,则会在此基础上加收。遇到这类目标时,--unblocker(proxy_pool=unblocker,即住宅代理和 Unblocker)会返回 ERR::PROXY::UNBLOCKER_ULTRA_REQUIRED(HTTP 422,不计费),错误封装中会附带提示 retry with --unblocker-ultra。--proxy-pool basic(数据中心代理,不启用 Unblocker)适用于数据中心代理可以访问的网站。--proxy-pool auto 会在请求发出前,根据目标网站的特征由 API 选择代理池:使用数据中心代理上的 Unblocker,或目标所需的代理池。所有目标均可使用此选项,包括需要 unblocker_ultra 的目标;这些目标会加收相应费用,定价则按实际使用的代理池计算。--proxy-pool 参数值优先于这些标志;--unblocker-ultra 优先于 --unblocker;--asp 是 --unblocker-ultra 的别名。其他 --proxy-pool 值(如 tor)会按原样发送;若同时指定其中一个标志,则会设置 asp=true。scrape batch、crawl start 和 crawl run 接受相同的标志。

这些标志的行为适用于 0.4.1 之后发布的 CLI 版本;运行 scrapfly version 可查看当前版本。在 0.4.1 及更早版本中,--unblocker 和 --asp 会发送 asp=true,而 --unblocker-ultra 尚不存在;--proxy-pool unblocker_ultra 和 --proxy-pool auto 在这些版本中也会选择对应代理池。API 的 asp 参数已弃用:请改用 proxy_pool(使用 Unblocker 时设为 unblocker_ultra)。迁移指南介绍了代理池推出前编写的请求。

方式 B(二进制/结构化输出): 为特定产品提供的专用命令。

  • scrapfly screenshot <url> ——以 JPG(默认格式)、PNG、WebP 或 GIF 格式截取整个页面或指定选择器。 完整的 ScreenshotConfig 配置项:--format、--capture、--resolution、 --country、--option、--wait-for-selector、--rendering-wait、 --auto-scroll、--js-file、--cache、--cache-ttl、--cache-clear、 --webhook、--vision-deficiency。
  • scrapfly extract --file page.html --prompt "..." ——对已获取的文档运行 AI/模板提取。 完整的 ExtractionConfig 配置:通过 --file 或标准输入提供正文;--content-type、--url、--charset、 --prompt | --model | --template | --template-file(四种提取模式中任选一种)、 --compression、--webhook、--request-timeout。
  • scrapfly crawl run <url> --max-pages N ——递归爬取,支持状态轮询、 内容流传输以及 WARC/HAR 产物。下载后: crawl parse har-list|har-get|warc-list|warc-get 可直接读取产物(无需单独的工具)。 请参阅下文的爬虫部分。

**路径 C(交互式浏览器——单次使用):**生成 CDP WebSocket URL, 交给 Playwright、Puppeteer 或 browser-use:

# plain session
scrapfly browser --pretty

# pre-navigate through /unblock so the target's anti-bot is bypassed
scrapfly browser https://target.example.com --unblock --country us --pretty

browser --unblock 和 scrape --unblocker 是两个名称相似、容易混淆的不同产品:--unblock 会通过 POST /unblock 启动 Cloud Browser 会话,而 --unblocker-ultra 或 --unblocker 会选择 Unblocker 池,这是无状态 scrape 或 crawl 的反机器人绕过功能。Cloud Browser 会话使用自己的代理池:datacenter、residential、tor 和 byop(browser --proxy-pool);对于 basic、unblocker、 unblocker_ultra 和 auto,则会返回 ERR::BROWSER::CONFIG_ERROR。

**路径 D(交互式浏览器——持久守护进程):**在多次 CLI 调用间保持一个 CDP 会话 处于打开状态。在守护进程的生命周期内,Cookie、标签页和 AXTree 引用都会持续保留。仅在 start 时需要 --session;后续调用会通过 ~/.scrapfly/sessions/.current 自动解析。

scrapfly browser --session demo --session-timeout 1800 start &
scrapfly browser navigate https://web-scraping.dev/login
scrapfly browser wait 'input[name=username]' --visible
scrapfly browser fill 'input[name=username]' user123
scrapfly browser fill 'input[name=password]' password
scrapfly browser click 'button[type=submit]'
scrapfly browser content --raw > page.html         # fully rendered HTML
scrapfly browser eval 'document.body.innerText'
scrapfly browser close                             # daemon + remote release

使用 Scrapfly 自定义浏览器时,fill / click / wait / slide 会自动使用 Antibot CDP 域,以模拟真人操作的时间间隔;content 使用 Page.getRenderedContent,会内联 iframe 内容。使用非 Scrapfly 浏览器时,CLI 会回退到原始的 Input.* 事件。

路径 E(大模型 Agent):scrapfly agent "<task>" --url <target> 会运行自主循环。模型会选择工具调用(open、snapshot、click、fill、scroll、screenshot、eval、unblock、done),CLI 在 Browser 中执行这些调用,并将结果反馈给模型,直到模型调用 done。 支持接入不同提供商:Anthropic(默认)、OpenAI、Gemini 或本地模型(Ollama / OpenAI-compatible)。基于 AXTree 的观测方式可减少 Token 用量。

**路径 F(仅 REST API):**跳过 CLI,直接调用 https://api.scrapfly.io/{scrape,screenshot,extraction,crawl},并使用 ?key=<API_KEY>。 官方 SDK:Python、TypeScript、Go、Rust。请参阅 docs.scrapfly.io。

路径 G(账户指标告警):scrapfly alert ... 可为 Scrapfly 的监控指标(成功率、拦截率、错误数、费用、延迟等)设置阈值规则,并通过 电子邮件、webhook 或应用内通知发送告警。适用于 Enterprise 套餐。

# Discover legal metrics
scrapfly alert metric-families

# Tune the threshold against the last 24h
scrapfly alert preview \
  --metric scrape.success_rate --comparator lt --threshold 95 \
  --sustained-minutes 10 --range-minutes 1440

# Create
scrapfly alert create \
  --name "Scrape Success Rate Low" \
  --metric scrape.success_rate --comparator lt --threshold 95 \
  --sustained-minutes 10 \
  --channel email:[email protected] \
  --channel webhook:https://hooks.example.com/scrapfly

alert list / get / update / snooze / unsnooze / test / delete / series / count-active 涵盖其余生命周期操作。每条告警的 HMAC 签名密钥由服务器生成,并可通过 alert get 获取,以验证 webhook。 详细参考文档: scrapfly-alerting 技能。

路径 H(定时执行周期性任务):scrapfly schedule 及各产品子命令组(scrapfly scrape schedule、 scrapfly screenshot schedule、scrapfly crawl schedule)可定义基于 cron 或间隔的周期性触发任务,并通过 webhook 传送结果。

# Daily scrape schedule (config payload from a file, '-' for stdin)
scrapfly scrape schedule create --cron "0 6 * * *" \
  --webhook my-hook --config ./scrape.json

# Interval schedule with an inline payload
scrapfly crawl schedule create --interval 6 --unit hour \
  --webhook my-hook --config-inline '{"url":"https://example.com"}'

# Cross-product lifecycle (top-level group)
scrapfly schedule list [--status ACTIVE|PAUSED|CANCELLED]
scrapfly schedule get <id>
scrapfly schedule update <id> --set-recurrence --cron "0 */2 * * *"
scrapfly schedule pause <id>     # / resume <id>
scrapfly schedule execute <id>   # fire now, ignoring next_scheduled_date
scrapfly schedule delete <id>    # terminal, cannot be resumed

必须指定 --webhook(每次触发的结果都会发送到此处)。 --cron 的优先级高于 --interval/--unit。--retry-on-failure --max-retries N(0..3)和 --allow-concurrency 可调整触发任务的行为。 路径 I(BYOP 出口对等端): scrapfly exit-peer 会安装并运行 自带代理连接器,通过 mTLS 隧道将 Scrapfly 流量经由 您自己的网络出口进行路由。

scrapfly exit-peer install            # download binary + per-customer cert bundle
scrapfly exit-peer run --name lab-01  # run the connector in the foreground
scrapfly exit-peer status             # local install state + cert lifetime

安装目录默认为 $SCRAPFLY_BYOP_DIR 或 $HOME/.scrapfly/byop。

身份验证

设置一次:

export SCRAPFLY_API_KEY=scp-live-...
# or, persisted:
scrapfly config set-key scp-live-...
# interactive (opens a browser to mint a key):
scrapfly auth login        # / logout / whoami

解析顺序:--api-key 标志 > SCRAPFLY_API_KEY 环境变量 > ~/.scrapfly/config.json。开发 / 可自托管的堆栈:使用 --host 和 --browser-host,或设置 SCRAPFLY_API_HOST / SCRAPFLY_BROWSER_HOST。

scrapfly status 在一次调用中打印 CLI 版本、身份验证状态和账户用量; scrapfly account 显示套餐、配额和订阅用量。

agent 模式使用的 LLM 提供商各自有对应的环境变量: ANTHROPIC_API_KEY、OPENAI_API_KEY、GEMINI_API_KEY 或 OLLAMA_HOST。 CLI 会自动检测第一个已设置的变量。

输出约定(适用于 LLM)

所有命令都会在 stdout 上输出稳定的 JSON 信封:

{"success": true,  "product": "scrape", "data": { ... }}
{"success": false, "product": "scrape", "error": {"code": "...", "message": "...", "http_status": 422}}

成功时退出代码为 0,发生任何错误时为 1。如果存在错误的 hint,其中会提供下一步操作,例如 retry with --unblocker-ultra。 --pretty 会将 JSON 替换为单行的人类可读摘要。二进制产物 (截图、爬取产物、会话录制)需要通过 -o <file> 或 -O <dir> 指定路径;如果两者都未提供,JSON 模式会返回 base64。 browser content --raw 会直接将 HTML 正文打印到 stdout,不含 信封(适用于管道操作)。

浏览器会话参考

生命周期
命令用途
browser --session <id> start [--url <target> --unblock]启动守护进程;在前台运行,也可用 & 将其置于后台
browser status打印 pid、ws_url、alive
browser stop仅关闭守护进程(远程会话会持续到超时)
browser close关闭守护进程 并 立即释放 Scrapfly 的远程浏览器
操作(发送给守护进程;运行 start 后可选用 --session)
命令说明
browser navigate <url>Page.navigate + 等待加载
browser snapshot带 refs(e1、e2、…)的 AXTree + ax_node_id + backend_node_id
browser click <locator>对 CSS/XPath/axNodeId 使用 Antibot.clickOn;对 refs 使用原始点击
browser fill <locator> <value> [--clear --wpm N]对 CSS/XPath/axNodeId 使用 Antibot.fill;对 refs 使用 Input.insertText
browser click-ai <description>通过 LLM 根据自然语言描述解析目标,然后点击
browser fill-ai <description> <value>通过 LLM 解析目标,然后填写
browser wait <selector> [--visible --timeout-ms N]Antibot.waitForElement(原生实现,不使用 JS 轮询)
browser slide <source> --target <sel> | --distance <px>Antibot.clickAndSlide(滑块验证码)
browser scroll <direction> [--amount px --ref e3]Input 滚轮事件
browser screenshot [--fullpage]通过 Page.captureScreenshot 获取 PNG;使用 -o/-O 指定文件
browser content [--raw] [--skip-iframes]Page.getRenderedContent——包含内联 iframe 的 HTML
browser eval <js>Runtime.evaluate,并等待 Promise
定位器

click / fill 接受以下任一种:

  • AXTree 引用 - e3,取自上一次 snapshot。使用原始 Input.* 路径。
  • CSS 选择器(默认)- input[name=username]
  • XPath - //button[text()="Submit"],搭配 --selector-type xpath
  • AX 节点 ID - 42,取自 snapshot 的 ax_node_id 字段,搭配 --selector-type axNodeId
  • AI 描述 - ai:<plain English>(或使用 click-ai / fill-ai 快捷命令)可让 LLM 根据实时快照解析引用。

对于 CSS/XPath/axNodeId,CLI 会通过 Scrapfly 浏览器上的 Antibot 执行操作。

录制、扩展
命令用途
browser list列出账户中的活跃 Browser 会话
browser video <run-id>下载会话录制文件(webm);需要 -o/-O
browser playback <run-id>获取调试运行的回放元数据
browser extensions list | get <id> | upload <path> | delete <id>管理账户浏览器扩展(.zip/.crx)
人工接管(VNC / WebRTC)和凭据保险库

这些标志适用于 browser、browser start 和 browser execute:

标志用途
--vault NAME --vault-key B64KEY附加凭据保险库;会在会话交接前解密条目并通过 CDP 推送。密钥仅由你持有,Scrapfly 永远不会存储它;如果省略密钥,会话将以 ERR::BROWSER::VAULT_KEY_INVALID 失败
--enable-vnc --vnc-password PW通过 VNC 暴露会话,以便人工接管
--enable-rtc --rtc-password PW [--rtc-username U]通过 WebRTC 实时视频暴露会话(用户名默认为 scrapfly)
--hitl-allowed-network IP|CIDR信任某个源地址范围,无需凭据即可连接(可重复指定)。此选项会替代密码要求,而非叠加;之后服务器会自行生成密钥
browser salt打印项目盐值 sha256(api_key)[:8]

查看器需要输入的 VNC 密码取决于端点。 Scrapfly 会在分配时为密码加上项目盐值前缀,而两个端点对其的检查方式不同:

端点要输入的密码
TCP 多路复用器上的原生客户端,vnc://<run_id>@<host>:5901<project_salt>-<vnc_password>
WebSocket,wss://<host>/run/<run_id>/vnc原始的 <vnc_password>

多路复用器会使用加盐后的形式进行 DES 挑战(原生客户端不会移除盐值),因此即使两个客户选择相同的密码,也不会发生冲突;WebSocket 处理程序则会在服务器端移除盐值,再执行相同的检查。browser start 会打印 TCP URL 和对应的加盐密码:

scrapfly browser --session demo --enable-vnc --vnc-password hunter2 start &
# [session demo] vnc vnc://01K5Z.../@browser.scrapfly.io:5901
# [session demo] vnc password <project_salt>-hunter2

vnc:// 用户名是运行 ID,只有在会话分配后才会生成,因此 browser start 会在连接后打印 URL。在 ws 模式下(scrapfly browser --enable-vnc --vnc-password PW),JSON 封套会包含 project_salt、加盐后的 vnc_password,以及带有 {run_id} 占位符的 vnc_url。

爬虫参考

提交 + 轮询
命令用途
crawl start <url>提交爬取任务;立即打印 UUID
crawl run <url>提交并轮询,直到状态变为 DONE / FAILED / CANCELLED
crawl watch <uuid>显示实时统计面板(已访问 / 已提取 / 失败 / 已跳过 / 队列 / 额度),直到任务结束
crawl status <uuid>获取状态;封套会提供顶层 terminal 字段(running|done|failed|cancelled),供 Shell 脚本使用
crawl urls <uuid> --status visited|pending|failed|skipped流式输出发现的 URL(分页)
crawl contents <uuid> --format markdown [--url URL --plain]批量 JSON 内容或单个 URL 的纯文本正文
crawl contents-batch <uuid> <url...> [--from-file F] --format markdown一次往返获取最多 100 个 URL
crawl cancel <uuid>停止正在运行的爬取任务
crawl artifact <uuid> --type warc|har -o file下载录制文件
crawl start / crawl run 的标志

所有已记录的 CrawlerConfig 字段均可通过标志设置:

标志对应字段
--max-pages Npage_limit
--max-depth Nmax_depth
--max-duration Nmax_duration(秒,15-10800)
--max-api-credit Nmax_api_credit
--exclude PATH / --include PATHexclude_paths / include_only_paths(可重复,互斥)
--ignore-base-pathignore_base_path_restriction
--follow-external / --allowed-external-domain Dfollow_external_links / allowed_external_domains
--follow-internal-subdomains true|false(三态)/ --allowed-internal-subdomain D对应字段
--header k=v(可重复)headers
--delay MS / --user-agent UA / --max-concurrency N / --rendering-delay MS请求配置
--use-sitemaps / --ignore-no-follow / --respect-robots-txt true|false策略
--cache / --cache-ttl S / --cache-clear缓存
--content-format F(可重复)/ --extraction-rules-file PATH内容与提取
--unblocker-ultra(或 --asp)/ --unblocker / --proxy-pool P / --country CCproxy_pool(unblocker_ultra / unblocker / P,以最后指定的为准)/ country
--webhook NAME / --webhook-event E(可重复)Webhook
从 WARC / HAR 文件中读取
scrapfly crawl artifact <uuid> --type warc -o crawl.warc
scrapfly crawl parse warc-list crawl.warc --pretty             # URLs + statuses
scrapfly crawl parse warc-get crawl.warc https://example.com \
  --raw > page.html                                             # body straight to stdout

scrapfly crawl artifact <uuid> --type har -o crawl.har
scrapfly crawl parse har-list crawl.har --pretty               # request table
scrapfly crawl parse har-get crawl.har https://example.com/api \
  --raw | jq .                                                  # extract one response

将文件路径设为 - 即可从标准输入读取,因此你可以直接通过管道传入 crawl artifact -o -。

核心 API 端点

产品端点CLI
网页抓取GET/POST /scrapescrapfly scrape <url>
截图POST /screenshotscrapfly screenshot <url>
提取POST /extractionscrapfly extract
爬虫POST /crawl + /crawl/{uuid}/{status,urls,contents,artifact}scrapfly crawl {start,run,status,urls,contents,cancel,artifact}
浏览器(CDP)wss://browser.scrapfly.io?api_key=...scrapfly browser
浏览器解封POST /unblockscrapfly browser <url> --unblock
停止浏览器会话POST /session/{id}/stopscrapfly browser close
会话录制GET /run/{id}/videoscrapfly browser video <run-id>
反馈POST /dashboard/api/feedback(位于 scrapfly.io,而非 API 主机)scrapfly feedback

快速示例

# A site that blocks: the Unblocker Ultra pool, never refused (CLI release after 0.4.1)
scrapfly scrape https://web-scraping.dev/products --render-js --unblocker-ultra --format markdown

# Scrape a JS-heavy page through the Unblocker pool with markdown output
scrapfly scrape https://web-scraping.dev/products --render-js --unblocker --format markdown

# Scrape many URLs in parallel (ndjson on stdout, one envelope per line)
scrapfly scrape https://web-scraping.dev/products \
               https://web-scraping.dev/product/1 \
               https://web-scraping.dev/product/2 \
               --format markdown --concurrency 5

# Or feed URLs from a file
scrapfly scrape --from-file urls.txt --format markdown | jq -c '.data.result.url'

# Pipe scrape body straight into AI extraction
scrapfly scrape https://web-scraping.dev/product/1 --render-js --proxified \
  | scrapfly extract --content-type text/html --prompt "name, price, sku"

# Screenshot into an auto-named file in a directory
scrapfly -O ./shots screenshot https://example.com --resolution 1920x1080

# Crawl synchronously with markdown content streaming
scrapfly crawl run https://example.com --max-pages 20 --content-format markdown

# Multi-call browser session: log in, dump rendered HTML, clean up
scrapfly browser --session demo --session-timeout 1800 start &
scrapfly browser navigate https://web-scraping.dev/login
scrapfly browser wait 'input[name=username]' --visible
scrapfly browser fill 'input[name=username]' user123 --wpm 280
scrapfly browser fill 'input[name=password]' password
scrapfly browser click 'button[type=submit]'
scrapfly browser content --raw > after-login.html
scrapfly browser close

# Hand a Scrapfly-unblocked CDP URL to browser-use
WS=$(scrapfly browser https://target.example.com --unblock --country us --pretty | jq -r .ws_url)
python examples/browser-use-with-scrapfly.py   # reads WS from scrapfly CLI

# LLM agent with structured output
ANTHROPIC_API_KEY=... scrapfly agent "Name and price of the first product" \
  --url https://web-scraping.dev/products \
  --schema '{"type":"object","properties":{"name":{"type":"string"},"price":{"type":"string"}},"required":["name","price"]}'

提交产品反馈

scrapfly feedback 可从终端提交关于 Scrapfly 某项功能的报告,例如 CLI、API、文档、仪表板、MCP 服务或技能。报告会写入与仪表板反馈小组件相同的存储,团队会在此查看报告。这不是支持渠道:不会创建工单,也不会收到回复,因此账号或集成问题仍应前往 https://scrapfly.io/dashboard/support。

scrapfly feedback --sentiment negative --feature crawler_api \
  --message "crawl status returned 200 with an empty urls array for ten minutes after the crawl finished" \
  --context "Mirroring a 300-page docs site, polling crawl status every 15s, CLI 0.4.1"

如果你是操作此 CLI 的 Agent:当某项 Scrapfly 功能在会话中表现出色、令人困惑、有误或不完整时,请在会话结束、用户的任务完成后,起草一份报告。将草稿展示给用户,只有在用户同意后才提交——报告会使用他们的 API 密钥发送,并关联他们的账号。

  • --sentiment negative 表示缺陷或阻碍导致命令无法运行;neutral 表示有阻碍或需要变通,但任务已完成;positive 表示运行正常,或某个步骤的表现超出预期。也要提交正面报告。
  • --message 说明命令及其执行结果,--context 说明目标和 CLI 版本。两者均需为 10-2000 个字符,且 --message 至少包含五个词:“它坏了”不算是可供他人采取行动的报告。
  • --feature 用于指定报告所属的产品领域。若值无效,系统会返回完整列表,你可以根据错误提示进行更正。
  • 如果存在编码 Agent 环境变量,--actor 默认为 agent,否则默认为 human。如果转述的是用户本人的原话,请传入 --actor human,并保留其原有措辞。
  • 报告应反映产品问题,而不是你自己的环境、模型的行为、你觉得不清楚的提示词,或你在下次调用中已解决的工具错误。
  • 提交失败绝不是让任务失败、停滞或重试的理由。遇到 429 时,表示账号的每小时额度已用尽:放弃提交报告。遇到其他错误时,将起草的 --message 和 --context 展示给用户,以便他们手动提交。

Shell 补全

Cobra 提供适用于 bash、zsh、fish 和 PowerShell 的补全脚本。只需安装一次:

# zsh
scrapfly completion zsh > "${fpath[1]}/_scrapfly"
# bash
scrapfly completion bash > /etc/bash_completion.d/scrapfly  # or ~/.bash_completion.d/
# fish
scrapfly completion fish > ~/.config/fish/completions/scrapfly.fish

MCP 服务

scrapfly mcp serve 通过 stdio 将 scrape、screenshot、extract、crawl_run 和 selector 作为 MCP 工具公开。将该二进制文件添加到兼容的客户端(Claude Desktop、Cursor、Claude Code):

{
  "mcpServers": {
    "scrapfly": {
      "command": "scrapfly",
      "args": ["mcp", "serve"],
      "env": { "SCRAPFLY_API_KEY": "scp-live-..." }
    }
  }
}

工具输入遵循 API,而不是 CLI 标志:proxy_pool 可取 basic、unblocker、unblocker_ultra、auto、tor 或 public_tor_pool(这是结果中 Tor 池的名称)。unblocker 和 asp 输入并非 CLI 的 --unblocker 和 --asp 标志:这些输入已弃用,请使用 proxy_pool(Unblocker 对应 unblocker_ultra)。有关代理池推出前编写的请求,请参阅迁移指南。

在 Agent 循环中也可以通过 find_selector 工具发现选择器——当模型想要生成可长期使用的 CSS 选择器,而不是依赖每个快照中的引用时,这会很有用。

参考资料

评论

支持 Markdown