webcli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesewebcli — Headless Browser CLI
webcli — 无头浏览器CLI
You have access to a headless browser via the command. Use it to navigate websites, read content, interact with elements, and take screenshots.
webcli你可以通过命令访问无头浏览器,用它来导航网站、读取内容、与元素交互以及截取屏幕截图。
webcliPrerequisites
前提条件
bash
npm install -g @erdinccurebal/webcli
npx playwright install chromiumHomepage: https://erdinccurebal.github.io/webcli/
Repository: https://github.com/erdinccurebal/webcli
bash
npm install -g @erdinccurebal/webcli
npx playwright install chromiumCommands Reference
命令参考
Navigation
导航
bash
webcli go <url> # Navigate to URL (auto-starts daemon)
webcli go <url> -w networkidle # Wait for network to settle
webcli go <url> -t mytab # Open in named tab
webcli back # Go back in history
webcli forward # Go forward
webcli reload # Reload current pagebash
webcli go <url> # 导航至指定URL(自动启动守护进程)
webcli go <url> -w networkidle # 等待网络稳定
webcli go <url> -t mytab # 在指定名称的标签页中打开
webcli back # 后退
webcli forward # 前进
webcli reload # 重新加载当前页面Reading Page Content
读取页面内容
bash
webcli source # Get full visible text of the page
webcli links # List all links (text + href)
webcli forms # List all forms with their inputs
webcli html <selector> # Get innerHTML of element
webcli attr <selector> <attribute> # Get element attribute valuebash
webcli source # 获取页面的全部可见文本
webcli links # 列出所有链接(文本+链接地址)
webcli forms # 列出所有表单及其输入字段
webcli html <selector> # 获取元素的innerHTML
webcli attr <selector> <attribute> # 获取元素的属性值Interaction
交互操作
bash
webcli click "<visible text>" # Click element by visible text
webcli clicksel "<css selector>" # Click element by CSS selector
webcli fill "<selector>" "<value>" # Fill an input field (preferred for forms)
webcli type "<text>" # Type with keyboard (for focused element)
webcli select "<selector>" "<val>" # Select dropdown option
webcli press Enter # Press keyboard key (Enter, Tab, Escape...)
webcli focus "<selector>" # Focus an elementbash
webcli click "<visible text>" # 通过可见文本点击元素
webcli clicksel "<css selector>" # 通过CSS选择器点击元素
webcli fill "<selector>" "<value>" # 填充输入字段(表单优先使用此命令)
webcli type "<text>" # 模拟键盘输入(针对已聚焦的元素)
webcli select "<selector>" "<val>" # 选择下拉选项
webcli press Enter # 按下键盘按键(Enter、Tab、Escape等)
webcli focus "<selector>" # 聚焦到指定元素Waiting
等待操作
bash
webcli wait "<selector>" # Wait for CSS selector to be visible
webcli waitfor "<text>" # Wait for text to appear on page
webcli sleep 2000 # Sleep for N millisecondsbash
webcli wait "<selector>" # 等待CSS选择器对应的元素可见
webcli waitfor "<text>" # 等待文本出现在页面上
webcli sleep 2000 # 休眠N毫秒Screenshots
屏幕截图
bash
webcli screenshot # Take screenshot (returns path)
webcli screenshot -o page.png # Save to specific filebash
webcli screenshot # 截取屏幕截图(返回文件路径)
webcli screenshot -o page.png # 保存到指定文件Browser Settings
浏览器设置
bash
webcli viewport 1920 1080 # Change viewport size
webcli useragent "<string>" # Change user agentbash
webcli viewport 1920 1080 # 修改视口尺寸
webcli useragent "<string>" # 修改用户代理Tab & Daemon Management
标签页与守护进程管理
bash
webcli tabs # List open tabs
webcli quit # Close current tab
webcli quit -t mytab # Close specific tab
webcli status # Show daemon info (PID, uptime, tabs)
webcli stop # Stop daemon and close browserbash
webcli tabs # 列出所有打开的标签页
webcli quit # 关闭当前标签页
webcli quit -t mytab # 关闭指定名称的标签页
webcli status # 显示守护进程信息(PID、运行时间、标签页)
webcli stop # 停止守护进程并关闭浏览器Global Options
全局选项
All commands support:
- — target a specific tab (default: "default")
-t, --tab <name> - — output as structured JSON
--json - — command timeout (default: 30000)
--timeout <ms>
所有命令均支持:
- — 目标指定标签页(默认值:"default")
-t, --tab <name> - — 以结构化JSON格式输出
--json - — 命令超时时间(默认值:30000)
--timeout <ms>
Best Practices
最佳实践
General workflow
通用工作流
- to navigate
webcli go <url> - to read the page content
webcli source - Use ,
webcli click,webcli fillto interactwebcli press - again to see the result
webcli source - if user wants visual confirmation
webcli screenshot
- 使用导航至目标页面
webcli go <url> - 使用读取页面内容
webcli source - 使用、
webcli click、webcli fill进行交互操作webcli press - 再次使用查看操作结果
webcli source - 如果用户需要视觉确认,使用
webcli screenshot
Form filling
表单填充
- Always use for input fields — it properly sets React/Vue controlled inputs
webcli fill - Use or
webcli clickfor buttonswebcli clicksel - Use to submit forms
webcli press Enter - After submitting, use then
webcli sleep 1000to check the resultwebcli source
- 始终使用填充输入字段——它能正确设置React/Vue的受控输入框
webcli fill - 使用或
webcli click点击按钮webcli clicksel - 使用提交表单
webcli press Enter - 提交后,使用然后
webcli sleep 1000检查结果webcli source
Multi-tab browsing
多标签页浏览
bash
webcli go https://site-a.com -t research
webcli go https://site-b.com -t reference
webcli source -t research # Read from specific tab
webcli source -t referencebash
webcli go https://site-a.com -t research
webcli go https://site-b.com -t reference
webcli source -t research # 读取指定标签页的内容
webcli source -t referenceError recovery
错误恢复
- If a command times out, try then retry
webcli sleep 2000 - If an element is not found, use to check what's on the page
webcli source - If the daemon seems stuck, use then retry the command
webcli stop - Use before interacting with dynamically loaded content
webcli wait "<selector>"
- 如果命令超时,尝试先执行再重试
webcli sleep 2000 - 如果未找到元素,使用检查页面上的内容
webcli source - 如果守护进程似乎卡住,使用然后重新执行命令
webcli stop - 与动态加载的内容交互前,使用等待元素加载完成
webcli wait "<selector>"
Important Notes
重要说明
- Always read the page with before trying to interact — understand what's on the page first
webcli source - Prefer over
webcli fillfor form inputswebcli type - Prefer (by text) over
webcli click(by selector) when possible — it's more robustwebcli clicksel - Use between rapid interactions to let pages update
webcli sleep - The daemon persists between commands — no need to re-navigate unless the page changes
- 在尝试交互前,务必先用读取页面内容——先了解页面上的元素
webcli source - 填充表单输入框时优先使用而非
webcli fillwebcli type - 可能的话,优先使用(通过文本)而非
webcli click(通过选择器)——它的鲁棒性更强webcli clicksel - 在快速交互之间使用,让页面有时间更新
webcli sleep - 守护进程会在命令之间保持运行——除非页面发生变化,否则无需重新导航