mcpField
B
browser-probe

browser-probe

github.com/adobe开发316238 次安装今天更新
代码仓库

关于 browser-probe

browser-probe 是用于通过 web CLI 诊断 CDN 机器人防护的技能。它会测试多种浏览器配置,并保存可供后续 web 命令使用的配置方案。

主要功能

  1. 01测试最多五种浏览器配置
  2. 02检测拦截信号
  3. 03保存浏览器配置方案
  4. 04报告探测失败及处理选项

适用场景

  1. 01在网页自动化前诊断页面拦截
  2. 02在多个 web 命令间复用可用配置

安装

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

$npx skills add https://github.com/adobe/skills --skill browser-probe

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

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.releaserc.json
CHANGELOG.md
package.json
references/
stealth-config.md

详细介绍

Browser Probe

检测 CDN 机器人防护是否会拦截无头 Chrome,并为其他 web 命令生成浏览器配置配方。

要求

PATH 中需有 Node 22+ 和 playwright-cli >= 0.1.20(playwright-cli --version)。 仅定位一次 web CLI:

# <skill-dir> is the directory containing this SKILL.md
WEB=$(command -v web || echo "node <skill-dir>/../../cli/dist/web.mjs")

然后运行 $WEB …;它只会在 stdout 上输出一个 JSON 文档, 因此可以安全地使用 $WEB … > file.json。 发布后可使用回退方案:npx -y @adobe/web-cli。使用绝对路径 <skill-dir>;不要 cd 进入该目录。

会话。 如果已设置 WEB_SESSION 或 PLAYWRIGHT_CLI_SESSION,不要传入 --session:每条 web 命令都会使用该浏览器,并保持其打开。否则可以选择一次性运行($WEB page tree "$URL" 会打开并关闭自己的浏览器),也可以启动浏览器并复用生成的名称: S=$($WEB browser open "$URL" | jq -r .session),然后使用 --session "$S"。 切勿自行编造固定的会话名称。

何时使用

当 web 命令以 3 退出(被拦截)、页面返回被拦截或为空(403、 “access denied”、验证码),或在自动化访问已知会拦截机器人的网站之前使用。

命令

$WEB probe "$URL" [--output <dir>]

它会尝试最多 5 种浏览器配置,并在首次成功时停止:

  1. default:无头 Chromium(基准配置)
  2. stealth:无头 Chromium + JS 隐身初始化脚本(修补 navigator.webdriver、插件和语言)
  3. stealth-ua:隐身模式 + User-Agent 覆盖(从 HTTP UA 标头中移除 HeadlessChrome)
  4. chrome:系统 Chrome + 隐身模式 + UA 覆盖(修复 TLS 指纹检测)
  5. persistent:系统 Chrome + 隐身模式 + UA 覆盖 + 持久化配置文件(应对 Cookie/会话挑战)

进度会输出到 stderr。--output 下的文件(默认为 ./.web): probe-<id>/probe-report.json,以及成功时的 probe-<id>/browser-recipe.json。路径 会以 recipePath 输出。使用 --save-recipe 时,配方会写入 --recipe(默认为 ./recipe.json),替换其中的 probe 条目,同时保留其他类型的条目。

读取 JSON

{ report: { url, timestamp, steps, firstSuccess, detectedSignals }, recipePath }

  • firstSuccess 非 null:该配置有效,且为满足要求的最低配置;recipePath 指向配方。
  • 带有 headerError 的步骤表示无法读取响应标头,因此 detectedSignals 可能不完整;请在报告中说明。
  • 将 detectedSignals 与 references/stealth-config.md 中的 Provider Signature Table 进行比对,以确认拦截原因。

退出代码 3(BLOCKED):所有步骤都被拦截,且不会写入配方。不要 继续使用无法正常工作的配置。报告:

Browser probe failed for <url>. No headless configuration could load the page.
  Tried: default, stealth, stealth-ua, chrome, persistent
  Detected signals: <detectedSignals>

  Options:
  1. Use --headed for manual browser interaction
  2. Provide pre-captured data (DOM snapshot, screenshots) manually
  3. Check if the URL requires authentication or VPN access

成功时报告:

Browser probe complete for <url>.
  Working config: <firstSuccess>
  Detected: <detectedSignals or "no bot protection detected">
  Recipe: <recipePath>

串联:使用配方

保存一次配方;之后每条浏览器命令(browser open、page *、ext launch)都会使用该配方启动,可通过 --recipe <file>、$WEB_RECIPE,或在 ./recipe.json 存在时使用它:

$WEB probe "$URL" --save-recipe                  # writes ./recipe.json
$WEB page tree "$URL"                            # picks it up
S=$($WEB browser open "$URL" | jq -r .session)

如果未使用 --save-recipe,请传入输出的路径:--recipe "$($WEB probe "$URL" | jq -r .recipePath)"。 配方仅在启动浏览器时生效;已打开的会话会继续使用自身配置。

配方是一个对象,其中每种类型对应一个条目数组。probe 条目的格式为 { url, config: { browserName, launchOptions }, persistent, stealth }(当 firstSuccess 为 stealth 或更后面的配置时,stealth: true:启动时会注入隐身脚本; 当配置为 persistent 时,persistent: true)。page overlays --save-recipe 会添加 overlays 条目,详见 page-prep 技能。

备用方案

playwright-cli -s <session> … 会驱动同一个浏览器。

评论

支持 Markdown