feat: finist chromium download douyin media

This commit is contained in:
2025-08-31 15:27:34 +08:00
parent 38dc501f4f
commit 075ed9296d
6 changed files with 233 additions and 123 deletions
+1 -5
View File
@@ -5,21 +5,17 @@ const userDataDir = './profiles/site1';
const startUrl = process.argv[2] || 'https://douyin.com';
const context = await chromium.launchPersistentContext(userDataDir, {
headless: false, // 首次建议“有头”,方便手工/2FA
headless: false,
args: ['--disable-blink-features=AutomationControlled'],
});
await context.addInitScript({ path: './userscripts/my-script.js' });
const page = context.pages()[0] || await context.newPage();
await page.goto(startUrl, { waitUntil: 'domcontentloaded' });
// 在这一步完成你的登录(手输或自动化都可)
console.log('>>> 请在打开的浏览器里完成登录,完成后回到终端按回车...');
process.stdin.resume();
await new Promise(r => process.stdin.once('data', r));
// 可选:导出 storageState 做备份(即使不用它,持久化目录也保存了)
await context.storageState({ path: `${userDataDir}/storageState.json` });
await context.close();
console.log('>>> 登录态已写入 profiles/site1/,后续可无头复用。');