SuperAPI AI 工具集

clone-page

前端与建站

查看项目

更新于 10-16 00:00

技能介绍

该技能用于克隆、复刻或还原网页,通过 Playwright 渐进式采集数据后分阶段构建 HTML/CSS。前置条件为 Node.js >= 18,Playwright 与 Chromium 首次运行时自动安装。采集脚本从技能目录下的 scripts/ 运行:node scripts/clone.mjs <url> <command> [options]。

提供两种还原模式。快速还原适合快速出原型、token 消耗少、几分钟完成,采集命令为 node scripts/clone.mjs <url> quick -o ./clone-data --scroll;数据源优先级中 screenshot.png 为视觉真相最高优先,其次 theme.json 设计令牌、skeleton.json DOM 骨架。还原时先看截图理解布局,再读 theme.json 提取主色、字体、间距、圆角、阴影等,粗读 skeleton.json 了解 section 划分,按 header→main→footer 逐 section 写 HTML/CSS,并用 theme.json 值作为 CSS 变量。

高精度还原适合生产环境、像素级还原,在快速还原基础上追加采集:先执行 quick,再用 styles 命令按 selector 逐 section 深入采集,如 node scripts/clone.mjs <url> styles -o ./clone-data --selector "header";需要时用 interact 采集交互态、responsive 采集多视口截图、assets 下载资源。数据源优先级中 nodes.json 提供精确 DOM 结构与 selector,styles.json 提供完整 computedStyle。还原时按 nodes.json 的 children 严格构建层级,按 styles.json 的 styleId 应用样式,对比截图微调。

采集命令包括 quick、full、init、skeleton、styles、interact、responsive、assets。查询命令 query.mjs 支持 summary、skeleton --depth、subtree、node、sections、section、find(按标签/文本/交互元素)、file 等。产出目录含 meta.json、screenshot.png、theme.json、skeleton.json、sections/、interactions/、responsive/、assets/。

需要登录的页面可连接已登录的 Chrome(先以 --remote-debugging-port=9222 启动并登录,再用 --connect-cdp http://localhost:9222),或用 --no-headless 显示浏览器手动登录。提示:截图是最终真相,数据与截图冲突时以截图为准;渐进式采集,先 quick 再按需 styles;selector 是桥梁;每个 Phase 独立增量追加;先粗后细。