Install
openclaw skills install chrome-automationLinux服务器Chrome浏览器自动化方案。支持2K高清截图、表单填写、自动登录、绕过反爬虫检测。适用于B站、YouTube等网站自动化操作。
openclaw skills install chrome-automation服务器环境下的Chrome浏览器自动化方案,支持2K高清截图和复杂交互操作。
# 2K高清截图(推荐默认)
google-chrome --headless=new --no-sandbox --disable-gpu \
--window-size=1920,1080 --force-device-scale-factor=2 \
--screenshot=/home/Kano/.openclaw/workspace/screenshot.png \
https://www.bilibili.com
参数说明:
| 参数 | 作用 |
|---|---|
--headless=new | 新版无头模式 |
--window-size=1920,1080 | 窗口分辨率 |
--force-device-scale-factor=2 | 2倍缩放(2K清晰度) |
--no-sandbox | 跳过沙箱(服务器必需) |
--disable-gpu | 禁用GPU(服务器必需) |
适用于: 填表、登录、发帖、绕过反爬虫检测
# Stealth模式截图
python3 ~/.openclaw/workspace/skills/chrome-automation/scripts/playwright_stealth.py <URL>
# 指定输出路径
python3 ~/.openclaw/workspace/skills/chrome-automation/scripts/playwright_stealth.py <URL> -o <输出路径>
Python调用:
import sys
sys.path.insert(0, '/home/Kano/.playwright-env/lib/python3.11/site-packages')
sys.path.insert(0, '/home/Kano/.openclaw/workspace/skills/chrome-automation/scripts')
from playwright_stealth import screenshot_with_stealth, auto_fill_form
# 截图(自动绕过反爬虫)
screenshot_with_stealth('https://bilibili.com')
# 自动填表登录
auto_fill_form('https://login.example.com', {
'#username': '用户名',
'#password': '密码'
}, submit_selector='button[type=submit]')
| 特性 | Chrome无头 | Playwright |
|---|---|---|
| 启动速度 | ⚡ 最快 | 🚀 快 |
| 截图质量 | ✅ 2K高清 | ✅ 2K高清 |
| 绕过反爬虫 | ⚠️ 容易被检测 | ✅ Stealth模式 |
| 填表/登录 | ❌ 不支持 | ✅ 完美支持 |
| 资源占用 | 低 | 中 |
| 推荐场景 | 简单截图 | 复杂自动化 |
# ========== 基础截图 ==========
# 默认分辨率
google-chrome --headless=new --no-sandbox --disable-gpu \
--screenshot=output.png https://example.com
# 2K高清(推荐)
google-chrome --headless=new --no-sandbox --disable-gpu \
--window-size=1920,1080 --force-device-scale-factor=2 \
--screenshot=output.png https://example.com
# 全页面截图
google-chrome --headless=new --no-sandbox --disable-gpu \
--window-size=1920,1080 --hide-scrollbars \
--screenshot=output.png https://example.com
# ========== Playwright ==========
# Stealth截图
python3 ~/.openclaw/workspace/skills/chrome-automation/scripts/playwright_stealth.py <URL>
# 自定义输出
python3 ~/.openclaw/workspace/skills/chrome-automation/scripts/playwright_stealth.py <URL> -o <路径>
| 组件 | 版本/路径 |
|---|---|
| Google Chrome | /usr/bin/google-chrome (v145+) |
| Playwright | ~/.playwright-env/ (v1.58.0) |
| Python虚拟环境 | ~/.playwright-env/ |
| Stealth脚本 | scripts/playwright_stealth.py |
/home/Kano/.openclaw/workspace/scripts/playwright_stealth.pyscripts/test_playwright.py