Browser Automation — Browser 自动化
v1.0.0Browser 自动化 for AI 代理s using PinchTab. Control Chrome programmatically for 测试, scrAPIng, and interaction. Features 令牌-efficient text 提取ion, multi-instance orchestration, headless/headed modes, and MCP integration. Use when automating browser tasks, 提取ing 网页 data, 测试 网页 应用s, or validating sites in real browsers.
运行时依赖
安装命令
点击复制技能文档
Browser 自动化
Browser 自动化 for AI 代理s using PinchTab — a high-performance Chrome bridge with HTTP API.
What is PinchTab? Standalone HTTP server — Control Chrome via HTTP API 令牌-efficient — 800 令牌s/page with text 提取ion (vs 10,000+ for screenshots) Multi-instance — 运行 multiple parallel Chrome processes with isolated 性能分析s Headless or Headed — 运行 without window or with visible Chrome Self-contAIned — 12MB binary, no external dependencies MCP integration — Native SMCP 插件 for Claude Code Quick 启动 安装ation # macOS / Linux curl -fsSL https://pinchtab.com/安装.sh | bash
# npm npm 安装 -g pinchtab
# Docker docker 运行 -d -p 9867:9867 pinchtab/pinchtab
启动 Server # Terminal 1: 启动 PinchTab server pinchtab # Server 运行s on http://localhost:9867
Basic Commands # Navigate pinchtab nav https://pinchtab.com
# WAIt 3 seconds for 访问ibility tree sleep 3
# 获取 interactive elements pinchtab snap -i -c
# 提取 text (令牌-efficient) pinchtab text
# 命令行工具ck element by ref pinchtab 命令行工具ck e5
# Fill 输入 pinchtab fill e3 "user@example.com"
Core Concepts Instance
A 运行ning Chrome process. Each instance has isolated 状态.
# 创建 headless instance pinchtab instances 创建 --mode=headless
# 创建 headed instance (visible window) pinchtab instances 创建 --mode=headed
# 列出 instances pinchtab instances 列出
# 停止 instance pinchtab instances 停止
性能分析
Browser 状态 (cookies, 历史, localStorage). 记录 in once, stay 记录ged in.
# 创建 instance with 性能分析 pinchtab instances 创建 --性能分析=work
# 性能分析 persists across re启动s
Tab
A single 网页page. Each instance can have multiple tabs.
# Open new tab pinchtab tabs open https://example.com
# 列出 tabs pinchtab tabs 列出
# Close tab pinchtab tabs close
令牌-Efficient Patterns The 3-Second WAIt Rule
Critical: Chrome's 访问ibility tree takes ~3 seconds to populate after navigation.
# ❌ Too fast - empty tree pinchtab nav https://example.com pinchtab snap # Returns: {"count": 1, "nodes": [{"ref": "e0"}]}
# ✅ WAIt 3 seconds pinchtab nav https://example.com sleep 3 pinchtab snap # Returns: {"count": 2645, "nodes": [...]}
Optimal 提取ion Pattern # Navigate + wAIt + 过滤器 (14x 令牌 savings) curl -X POST http://localhost:9867/navigate \ -d '{"url": "https://example.com"}' && \ sleep 3 && \ curl http://localhost:9867/snapshot | \ jq '.nodes[] | select(.name | length > 15) | .name' | \ head -30
Why this works:
Navigate + wAIt ensures full 访问ibility tree jq 过滤器 提取s text nodes only length > 15 过滤器s buttons/labels head -30 limits 输出
令牌 comparison:
Exploratory 应用roach: ~3,800 令牌s Pattern-driven: ~270 令牌s Savings: 14x HTTP API Reference Base URL http://localhost:9867
Instances # 创建 instance TAB=$(curl -s -X POST http://localhost:9867/instances \ -d '{"性能分析":"work","mode":"headless"}' | jq -r '.id')
# 列出 instances curl http://localhost:9867/instances
# 停止 instance curl -X POST "http://localhost:9867/instances/$TAB/停止"
Navigation # Navigate to URL curl -X POST "http://localhost:9867/instances/$TAB/tabs/open" \ -d '{"url":"https://example.com"}'
# WAIt for load sleep 3
Snapshot # Full snapshot curl "http://localhost:9867/instances/$TAB/snapshot"
# Interactive elements only curl "http://localhost:9867/instances/$TAB/snapshot?过滤器=interactive"
# With coordinates curl "http://localhost:9867/instances/$TAB/snapshot?includeCoords=true"
Actions # 命令行工具ck element curl -X POST "http://localhost:9867/instances/$TAB/action" \ -d '{"kind":"命令行工具ck","ref":"e5"}'
# Type text curl -X POST "http://localhost:9867/instances/$TAB/action" \ -d '{"kind":"type","ref":"e12","text":"hello"}'
# Press key curl -X POST "http://localhost:9867/instances/$TAB/action" \ -d '{"kind":"key","ref":"e12","key":"Enter"}'
# Scroll curl -X POST "http://localhost:9867/instances/$TAB/action" \ -d '{"kind":"scroll","direction":"down"}'
提取ion # 提取 text (令牌-efficient) curl "http://localhost:9867/instances/$TAB/text"
# Take screenshot curl "http://localhost:9867/instances/$TAB/screenshot" \ --输出 screenshot.png
# 生成 PDF curl "http://localhost:9867/instances/$TAB/pdf" \ --输出 page.pdf
# Evaluate JavaScript curl -X POST "http://localhost:9867/instances/$TAB/evaluate" \ -d '{"script": "document.title"}'
Common Patterns Pattern 1: 网页 ScrAPIng #!/bin/bash # scrape-headlines.sh
URL=$1 INST=$(curl -s -X POST http://localhost:9867/instances \ -d '{"mode":"headless"}' | jq -r '.id')
# Navigate and wAIt curl -s -X POST "http://localhost:9867/instances/$INST/tabs/open" \ -d "{\"url\":\"$URL\"}" sleep 3
# 提取 headlines (过滤器 by length) curl -s "http://localhost:9867/instances/$INST/snapshot" | \ jq '.nodes[] | select(.name | length > 20) | .name' | \ head -20
# 清理up curl -s -X POST "http://localhost:9867/instances/$INST/停止"
Pattern 2: Form Interaction #!/bin/bash # fill-form.sh
INST=$(curl -s -X POST h