Claude Code
让 Claude Code 通过 MCP 创建、体检、操作你的 Nullprint 环境。
用 CDP 把 Playwright 脚本挂到任意 Nullprint 环境上,指纹和代理原样保留。
Playwright 是微软开源的浏览器自动化库。由 Nullprint 启动环境,Playwright 通过 Chrome DevTools 协议接上去。
~/.nullprint/daemon.json(Windows:%USERPROFILE%\.nullprint\daemon.json),key 也能在「自动化」页面找到。POST /profiles/{name}/external-debug-grant 带 x-np-stepup 票,再 PATCH /profiles/{name} 传 {"launch": {"externalDebug": true}}。两样缺一个,cdp_endpoint 都一直是 null——环境默认不开调试端口。pip install requests playwrightimport json, os, time, requests
from playwright.sync_api import sync_playwright
cfg = json.load(open(os.path.expanduser("~/.nullprint/daemon.json")))
BASE = f"http://127.0.0.1:{cfg['port']}"
H = {"X-API-Key": cfg["api_key"]}
NAME = "shop-01" # the internal ID from GET /profiles, not the display label
requests.post(f"{BASE}/profiles/{NAME}/launch", json={"headless": False}, headers=H).raise_for_status()
while True: # launch is asynchronous
p = requests.get(f"{BASE}/profiles/{NAME}", headers=H).json()
if p.get("status") == "running" and p.get("cdp_endpoint"):
break
time.sleep(1)
with sync_playwright() as pw:
browser = pw.chromium.connect_over_cdp(p["cdp_endpoint"])
ctx = browser.contexts[0]
page = ctx.pages[0] if ctx.pages else ctx.new_page()
page.goto("https://example.com")
print(page.title())
browser.close() # only disconnects
requests.post(f"{BASE}/profiles/{NAME}/stop", headers=H) # this closes the browserchromium.connectOverCDP(endpoint)。完整 API 文档: 本地 API 文档
launch.debugPort。不会,只是断开连接;要关请调 POST /profiles/{name}/stop。
能:PATCH /profiles/{name} 带 proxy,或者 POST /proxies 加进代理池再分配。
启动时传 "headless": true。