← 返回
未分类 中文

sjht-web-screenshot

Capture screenshots of web pages running on local or remote servers using Puppeteer in headless Chromium. Use when user asks to screenshot web pages, capture...
使用Puppeteer在无头Chromium中对网页进行截图。用于当用户要求截图时使用。
aowind aowind 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 478
下载
💾 2
安装
1
版本
#latest

概述

Web Screenshot

Capture screenshots of web pages (especially SPA applications) with automatic login handling.

Dependencies

  • puppeteer-core (npm global)
  • chromium-browser (/usr/bin/chromium-browser)
  • Node.js

Verify with: which chromium-browser && npm ls -g puppeteer-core

Quick Start

node <skill_dir>/scripts/screenshot.js <config.json>

Config Format

{
  "baseUrl": "http://192.168.7.66:8080",
  "outputDir": "/root/screenpics/my-capture",
  "resolution": [1920, 1080],
  "login": {
    "url": "/login",
    "usernameSelector": "input[placeholder='请输入用户名']",
    "passwordSelector": "input[type='password']",
    "submitSelector": "button.el-button--primary",
    "credentials": { "username": "admin", "password": "123456" }
  },
  "pages": [
    { "name": "01_dashboard", "path": "/dashboard", "waitMs": 3000 },
    { "name": "02_project_list", "path": "/project/list", "waitMs": 2000 }
  ],
  "descriptions": {
    "01_dashboard": "工作台首页,展示KPI卡片和图表。",
    "02_project_list": "项目管理列表页面。"
  }
}

Login Flow (SPA Authentication)

The script handles Vue/React SPA login by:

  1. Navigating to the login page
  2. Setting input values via native HTMLInputElement.value setter + dispatching input events (Vue-reactive compatible)
  3. Clicking the submit button
  4. Waiting for SPA router navigation (URL change)
  5. Using Vue's $router.push() for subsequent page navigation (avoids Pinia/Redux store reset on full page reload)

Fields

FieldRequiredDescription
------------------------------
baseUrlBase URL of the web app
outputDirOutput directory for screenshots
resolutionNoViewport size [width, height], default [1920, 1080]
loginNoLogin config (skip for public pages)
login.usernameSelector✅*CSS selector for username input
login.passwordSelector✅*CSS selector for password input
login.submitSelector✅*CSS selector for submit button
login.credentials✅*{ username, password }
pagesArray of pages to capture
pages[].nameFilename prefix (e.g. 01_dashboard)
pages[].pathURL path (e.g. /dashboard)
pages[].waitMsNoExtra wait in ms after navigation (default 2000)
descriptionsNoMap of name → description text (included in result.json)

Output

  • {outputDir}/{name}.png — one PNG per page
  • {outputDir}/result.json — metadata with filenames, titles, URLs, descriptions

result.json Format

{
  "project": "auto-generated",
  "captureDate": "2026-03-22",
  "baseUrl": "...",
  "resolution": "1920x1080",
  "screenshots": [
    {
      "filename": "01_dashboard.png",
      "title": "Dashboard",
      "url": "...",
      "description": "..."
    }
  ]
}

Capture Login Page Too

To include the login page as the first screenshot, add it to pages with a special flag:

{
  "pages": [
    { "name": "00_login", "path": "/login", "isLoginPage": true, "waitMs": 2000 }
  ]
}

When isLoginPage: true, the script captures this page before performing login.

Advanced: Custom Vue Store Login

If the form-based login doesn't work (e.g., custom auth flow), use storeLogin instead:

{
  "login": {
    "url": "/login",
    "storeLogin": {
      "storeName": "user",
      "method": "login",
      "args": ["平台管理员"]
    }
  }
}

This directly calls pinia._s.get(storeName).method(...args) via CDP.

Troubleshooting

  • Blank charts (ECharts/Chart.js): Headless Chromium has no GPU. Charts using Canvas may render empty. Use --disable-gpu (already included).
  • Redirected to login on all pages: Login failed. Check selectors match the actual form elements. Try storeLogin approach.
  • SPA navigation not working: Ensure login section is configured. Without login, page.goto() is used instead of $router.push().

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-31 00:34 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 195 📥 67,421
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 72 📥 181,459
it-ops-security

sjht-ssh-ops

aowind
SSH密钥管理和远程服务器运维工具,用于生成密钥、部署公钥实现免密登录、测试连接、查看主机信息、远程执行运维命令。适用于连接远程服务器、配置免密登录、管理服务器、部署应用及执行命令。触发短语包括:SSH登录、免密登录、服务...
★ 0 📥 738