据 AlphaMoat 统计,截至 2026-09,Browser Session Manager 累计下载 2,082 次、获 1 个星标,在全部 5,078 个 AI 技能中排名第 4,373 位,在「开发编程」分类(577 个)中排名第 527 位。
| 平台 | 累计安装 | 累计下载 | 星标 | 评论 |
|---|---|---|---|---|
| ClawHub ↗ | 53 | 1,717 | 1 | - |
| SkillHub ↗ | 136 | 2,082 | 1 | — |
各平台的计数口径不同,统计时间不一致。
该技能记录了通过 Playwright 管理即梦浏览器会话并操作网页生成流程的方法,涵盖图片准备、Cookie 与 LocalStorage 注入、表单交互和提交状态检查。文档指出官方提供网页界面但没有开放 API。会话数据可能等同于账户凭据,必须限制本地访问并避免放入共享临时目录或版本库;自动化还可能上传素材或提交生成请求并消耗额度。仅在授权账户和隔离环境中使用,执行前检查输入与提交内容。
资料发布于 2026-10-29
以下是根据技能文档生成的示例,不代表实际运行结果。
2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。
| 月份 | 累计下载 | 环比 | 星标 |
|---|---|---|---|
| 2026-09 | 2,082 | — | 1 |
| 2026-08 | 1,774 | +8.2% | 1 |
| 2026-07 | 1,640 | — | 1 |
| 2026-05 | 1,275 | — | 1 |
| 2026-03 | 902 | — | 1 |
以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。
# 即梦AI (Jimeng) 视频自动化生成完全指南 > **TL;DR**: 本文记录如何通过 Playwright + 浏览器 Session 管理,实现即梦AI视频生成的全自动化。包含图片压缩、Cookie 注入、表单填写、视频提交等完整流程。 --- ## 📋 背景 即梦AI (jimeng.jianying.com) 是字节跳动旗下的 AI 视频生成平台。官方提供了 Web 界面,但没有开放 API。当我们需要批量生成视频或集成到工作流时,就需要通过浏览器自动化来实现。
## 🎯 核心挑战
1. **登录状态保持**: 需要正确处理 Cookies 和 LocalStorage
2. **文件上传**: 需要压缩图片到合适大小(WebP 格式最佳)
3. **动态表单**: 需要等待元素加载、处理弹窗
4. **提交检测**: 需要检测页面跳转和生成状态
## 🛠️ 技术栈
- **Playwright**: 浏览器自动化框架
- **ImageMagick**: 图片压缩(convert 命令)
- **Node.js**: 脚本运行环境
---
## 📁 目录结构
```
workspace/
├── screenshots/
│ └── YYYYMMDD_HHMMSS/ # 按时间戳组织的截图
│ ├── 01_initial.png
│ ├── 02_start_uploaded.png
│ └── ...
├── skills/
│ ├── browser-session-manager/ # Session 管理 Skill
│ └── web-form-automation/ # 表单自动化 Skill
└── session-data.json # Cookie 数据文件
```
---
## 🚀 完整实现步骤
### 1. 准备阶段:图片压缩
即梦对上传图片有大小限制,必须先压缩:
```bash
# 转换为 WebP 格式,压缩到 30-50KB
convert start.png start.webp
convert end.png end.webp
# 验证大小
ls -lh *.webp
# -rw-r--r-- 1 node node 88K Feb 15 14:59 start.webp
# -rw-r--r-- 1 node node 54K Feb 15 14:59 end.webp
```
**⚠️ 重要**: PNG 原图可能 4MB+,直接上传会失败。WebP 格式可压缩 99% 且画质损失极小。
---
### 2. Session 数据准备
从浏览器导出 Cookie 和 LocalStorage,保存为 JSON:
```json
{
"exportTime": "2026-02-15T14:55:58.374Z",
"url": "https://jimeng.jianying.com/ai-tool/home?type=video",
"hostname": "jimeng.jianying.com",
"cookies": [
{
"name": "sessionid",
"value": "xxx",
"domain": ".jianying.com",
"path": "/",
"secure": false,
"httpOnly": true,
"sameSite": "unspecified"
}
],
"localStorage": {
"dreamina__generator_video_modelKey": "\"dreamina_seedance_40_pro\"",
"DREAMINA_THEME": "light"
},
"sessionStorage": {}
}
```
**获取方法**: 使用浏览器扩展(如 "Cookie-Editor")导出,或从 DevTools Application 面板复制。
---
### 3. 核心自动化脚本
```javascript
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');
async function generateVideo(sessionFile, startImage, endImage, prompt, screenshotDir) {
// 读取 Session 数据
const sessionData = JSON.parse(fs.readFileSync(sessionFile, 'utf8'));
// 启动浏览器
const browser = await chromium.launch({
headless: true,
args: ['--no-sandbox']
});
const context = await browser.newContext();
const page = await context.newPage();
// ===== 关键步骤 1: 设置 Cookies =====
if (sessionData.cookies) {
const cookiesByDomain = {};
for (const cookie of sessionData.cookies) {
// 修复 sameSite 值
let sameSite = cookie.sameSite;
if (sameSite === 'unspecified') sameSite = 'Lax';
if (sameSite === 'no_restriction') sameSite = 'None';
const fixedCookie = { ...cookie, sameSite };
const domain = cookie.domain || '.jianying.com';
if (!cookiesByDomain[domain]) cookiesByDomain[domain] = [];
cookiesByDomain[domain].push(fixedCookie);
}
for (const [domain, cookies] of Object.entries(cookiesByDomain)) {
try {
await context.addCookies(cookies);
} catch (e) {
console.log(`Cookie 设置失败: ${e.message}`);
}
}
}
// ===== 关键步骤 2: 导航并注入 LocalStorage =====
await page.goto('https://jimeng.jianying.com/ai-tool/home?type=video', {
waitUntil: 'domcontentloaded',
timeout: 60000
});
await page.waitForTimeout(3000);
// 注入 LocalStorage
await page.evaluate((data) => {
for (const [key, value] of Object.entries(data.localStorage || {})) {
try { localStorage.setItem(key, value); } catch (e) {}
}
}, sessionData);
// 刷新使存储生效
await page.reload({ waitUntil: 'domcontentloaded' });
await page.waitForTimeout(3000);
// ===== 关键步骤 3: 处理登录弹窗 =====
try {
const agreeBtn = await page.getByText('同意').first();
if (await agreeBtn.isVisible({ timeout: 3000 })) {
await agreeBtn.click();
await page.waitForTimeout(2000);
}
} catch (e) {
// 没有弹窗,继续
}
// ===== 关键步骤 4: 上传首帧图片 =====
const startBtn = await page.getByText('首帧').first();
await startBtn.click();
await page.waitForTimeout(1500);
const fileInput = await page.locator('input[type="file"]').first();
await fileInput.setInputFiles(startImage);
await page.waitForTimeout(3000); // 等待上传完成
// ===== 关键步骤 5: 上传尾帧图片 =====
const endBtn = await page.getByText('尾帧').first();
await endBtn.click();
await page.waitForTimeout(1500);
const fileInputs = await page.locator('input[type="file"]').all();
await fileInputs[fileInputs.length - 1].setInputFiles(endImage);
await page.waitForTimeout(3000);
// ===== 关键步骤 6: 选择模型 =====
const modelBtn = await page.getByText('Seedance 2.0 Fast').first();
await modelBtn.click();
await page.waitForTimeout(2000);
// 选择 Seedance 2.0(非 Fast 版本)
const seedance20 = await page.getByText('Seedance 2.0').nth(1);
await seedance20.click();
await page.waitForTimeout(1500);
// ===== 关键步骤 7: 设置时长为 15s =====
const durationBtn = await page.getByText('5s').first();
await durationBtn.click();
await page.waitForTimeout(1500);
const fifteen = await page.getByText('15s').first();
await fifteen.click();
await page.waitForTimeout(1500);
// ===== 关键步骤 8: 输入提示词 =====
const textarea = await page.locator('textarea').first();
await textarea.click();
// 使用 pressSequentially 模拟真实打字,触发输入事件
await textarea.pressSequentially(prompt, { delay: 30 });
await page.waitForTimeout(3000);
// ===== 关键步骤 9: 提交生成 =====
const submit = await page.locator('button[class*="submit"]').first();
await submit.click({ force: true }); // force: true 确保能点击
await page.waitForTimeout(2000);
// ===== 关键步骤 10: 检测页面跳转 =====
await page.waitForTimeout(3000);
const currentUrl = page.url();
if (currentUrl.includes('/generate')) {
console.log('✅ 成功跳转到生成页面');
}
// 等待 5 秒查看生成状态
await page.waitForTimeout(5000);
await page.screenshot({ path: path.join(screenshotDir, 'final.png') });
await browser.close();
}
```
---
## ⚠️ 踩坑记录
### 1. Cookie sameSite 问题
**错误**: `browserContext.addCookies: cookies[3].sameSite: expected one of (Strict|Lax|None)`
**解决**: 导出时 `sameSite: 用 gh 命令行工具查看 GitHub 上的 PR 检查、工作流运行与 API 查询的技能。
聚合 16 个搜索引擎、无需 API Key 的检索技能。
用命令行直接列出、配置、授权并调用 MCP 服务与工具。
根据文字描述生成 Mermaid 图表代码。
用受管 OAuth 访问 YouTube Data API,检索视频并管理频道内容。
通过受管的 OAuth 连接访问 GitHub REST API。
覆盖规划、实现、验证与测试的编码工作流技能。
整理 Docker 常用命令与容器工作流的技能。
数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。