har-derived-api-client
它能做什么
这项技能让你的 AI 在浏览器使用网站时观察其网络活动,然后把记录转化为一个直接调用网站数据的简单客户端。适合需要自动化一个没有公开 API 的网站的开发者。
适用场景
- ✓你想为一个没有公开 API、但以 JSON 加载数据的网站构建客户端的时候。
- ✓你的 AI 即将重复许多次相同的浏览器操作,而直接请求会更快的时候。
- ✓你想自动化网站使用的自动补全或搜索功能的时候。
技能链接
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/web-development/har-derived-api-client/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请构建一个小型客户端,直接搜索这个网站的列表,这样我就不必每次都点击页面。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能把浏览器的网络流量记录到一个 HAR 文件中,然后提取页面使用的接口。你的 AI 使用普通的 HTTP 工具重放这些请求,并沿用你已有的登录会话。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
HAR-Derived API Client
Drive a website once with a real browser while recording its network traffic to a HAR file, then distill that HAR into the site's private JSON API so you can call it directly with plain HTTP — far cheaper and faster than browser-controlling the page on every request. Credit: trick by Jared Longster, popularized by Dax (thdxr). This captures and replays; it does NOT bypass auth, solve CAPTCHAs, or defeat bot-detection — if the site needs a logged-in session, you carry its headers/cookies forward, you don't forge them.
The scripts are stdlib-plus-Playwright: capture needs Playwright, derivation
is pure stdlib, replay needs only requests/httpx (or curl).
Covers every Hermes browser pathway: the default local Chromium that
browser_exec drives, plus the cloud/remote backends (Browserbase, Browser-Use, Firecrawl)
and any /browser connect CDP endpoint. There are two capture scripts — one
for a browser you launch, one for a browser you attach to over CDP — because
HAR recording works differently in each case (see How to Run).
When to Use
- "Build a CLI/client for <website>" — derive its API instead of scripting clicks.
- "This site has no public API but the page clearly fetches JSON."
- You're about to loop
browser_execnavigations for the same query repeatedly — stop and derive the endpoint once. - Reverse-engineering an autocomplete, search, feed, or checkout XHR.
- You captured a session on a cloud backend (Browserbase / Browser-Use / Firecrawl) or via
/browser connectand want the API without re-renting the browser.
Prerequisites
- Playwright + a browser binary (capture step only):
pip install playwrightthenplaywright install chromium --no-shell- (If a system Playwright already has browsers under
~/.cache/ms-playwright, reuse it.)
requestsorhttpxfor the replay step (stdliburllibalso works).- No API keys. Any keys/tokens the client needs are the ones the HAR captured.
- For the CDP path (
har_capture_cdp.py): a reachable CDP endpoint. On Hermes, run/browser connectto print the active endpoint, or readBROWSER_CDP_URL/browser.cdp_urlin config. Cloud backends expose it ascdpUrl/connectUrl.
How to Run
Scripts under this skill's scripts/, invoked through the terminal tool.
Pick the capturer by pathway — this is the part that trips people up:
| Browser pathway | How Hermes reaches it | Capturer |
|---|---|---|
Local Chromium (default browser_exec browser) |
launched locally | har_capture.py |
| Browserbase / Browser-Use / Firecrawl (cloud) | CDP (cdpUrl) |
har_capture_cdp.py |
/browser connect <url> / BROWSER_CDP_URL |
CDP | har_capture_cdp.py |
Rule of thumb: if Hermes launched the browser, use har_capture.py; if it
connected to one over CDP, use har_capture_cdp.py. har_capture.py uses
Playwright's record_har_path, which only works on a locally-owned context.
har_capture_cdp.py attaches with connect_over_cdp() and assembles the HAR
from page.on("request"/"response") events, because record_har_path is
unavailable on a connected browser.
Then, for either path:
har_to_client.py— filters the HAR to XHR/fetch/JSON, groups by endpoint, and prints params, headers, bodies, and replay hints (User-Agent / cookie / auth).
Resolve paths against this skill's directory. Canonical loop:
# 1a. Capture, LOCAL browser (Hermes launched it)
python3 scripts/har_capture.py "https://SITE/" out.har \
--action "fill:input[name=search]:my query" --action "sleep:3" --wait 2
# 1b. Capture, CDP browser (cloud backend or /browser connect)
# get the endpoint from /browser connect or BROWSER_CDP_URL
python3 scripts/har_capture_cdp.py "ws://HOST/devtools/browser/..." out.har \
--goto "https://SITE/" --action "fill:input[name=search]:my query" \
--action "sleep:3" --wait 2
# 2. Derive — read the endpoints out of the HAR
python3 scripts/har_to_client.py out.har --host SITE --max-body 400
# 3. Replay — write a tiny client from the printed endpoint (see Procedure)
Quick Reference
har_capture.py <url> <out.har> [--wait S] [--headed] [--action SPEC ...]
action SPEC: fill:SELECTOR:TEXT | press:SELECTOR:KEY | click:SELECTOR
goto:URL | sleep:SECONDS (run in order after page load)
use when Hermes LAUNCHED the browser (local browser_exec default)
har_capture_cdp.py <cdp_url> <out.har> [--goto URL] [--wait S] [--action SPEC ...]
sa
常见问题
它能绕过登录或验证码吗?
不能。技能说明它不会绕过身份验证、破解验证码或规避机器人检测。
它支持哪些浏览器?
技能涵盖本地 Chromium 浏览器,以及云端或远程浏览器后端,使用两个捕获脚本。
运行捕获需要什么?
捕获需要 Playwright,而推导和重放步骤只需要标准 Python 或 curl。
详情
热度
- GitHub 星标
- 260k
- 排名
- #578
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-merge-conflict-arbiter
260k以中立第三方的身份,解决两个智能体分支之间的 git 合并冲突,为代码仓库生成一个合并结果。
antigravity-cli
260k指导你安装、更新和排查 Antigravity 命令行工具,包括其插件、登录和沙盒。
blackbox
260k让你的智能体把编程任务交给 Blackbox AI 命令行工具,它会运行多个 AI 模型并挑选最佳结果。
dynamic-workflow
260k教你的智能体把大量相似的工作保存为脚本批量运行,使只有经过验证的结果才返回主对话。