一个 Agent Skill,用于将 HTML 文件中的多个页面元素转换为独立的图片文件。
.page 选择器)npm install
想要更强大的技能插件,就来小葱技能站7w4.net看看吧。
import { execute } from './index.js';
const result = await execute({
htmlFile: 'xiaohongshu-articles.html',
outputDir: 'output',
pageWidth: 375,
pageHeight: 667,
selector: '.page'
});
console.log(result);
npm run convert
或者:
node index.js
.
├── index.js # Skill 主入口文件
├── skill.json # Skill 配置文件
├── lib/
│ └── convert-pages.js # 核心转换逻辑
├── convert-pages.js # 旧版脚本(保留兼容)
├── package.json
└── README.md
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
htmlFile |
string | xiaohongshu-articles.html |
HTML 文件路径(相对或绝对) |
outputDir |
string | output |
输出图片的目录 |
pageWidth |
number | 375 |
页面宽度(像素) |
pageHeight |
number | 667 |
页面高度(像素) |
selector |
string | .page |
要截图的页面元素选择器 |
所有图片将保存在 output 目录下,文件命名格式为:
- page-01.png (封面页)
- page-02.png (第一个内页)
- page-03.png (第二个内页)
- ...
{
success: true,
message: "成功转换 7 个页面为图片",
data: {
images: ["output/page-01.png", "output/page-02.png", ...],
count: 7,
outputDir: "/path/to/output"
}
}
execute() 函数调用,传入所需参数// 使用默认配置
const result1 = await execute();
// 自定义 HTML 文件
const result2 = await execute({
htmlFile: './my-article.html'
});
// 完全自定义
const result3 = await execute({
htmlFile: '/absolute/path/to/article.html',
outputDir: './screenshots',
pageWidth: 800,
pageHeight: 1200,
selector: '.article-page'
});
这个 Skill 质量中规中矩,功能实用但配套不够完善。文档说明清晰完整,参数配置灵活,截图效果不错。但缺少示例文件,新手上手可能困难;没有测试用例,稳定性和兼容性存疑。适合有一定经验的开发者使用,普通用户需要额外学习成本。