26 lines
822 B
JavaScript
26 lines
822 B
JavaScript
import { chromium } from 'playwright';
|
|
import { config, datasets } from './config.js';
|
|
|
|
const target = process.argv[2] || 'orders'; // orders | bills | customers
|
|
const dataset = datasets[target];
|
|
if (!dataset) {
|
|
console.error(`未知页面: ${target},可选: orders, bills, customers`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`正在打开: ${dataset.heading} (${dataset.url})`);
|
|
|
|
const context = await chromium.launchPersistentContext(config.userDataDir, {
|
|
channel: 'chrome',
|
|
headless: false,
|
|
acceptDownloads: true,
|
|
downloadsPath: config.downloadDir,
|
|
});
|
|
|
|
const page = context.pages()[0] || (await context.newPage());
|
|
await page.goto(dataset.url, { waitUntil: 'domcontentloaded' });
|
|
console.log('页面已打开,浏览器保持运行。按 Ctrl+C 关闭。');
|
|
|
|
// 保持进程运行
|
|
await new Promise(() => {});
|