项目初始化
This commit is contained in:
25
aliyun-sync/aliyun-aps-sync/src/open-page.js
Normal file
25
aliyun-sync/aliyun-aps-sync/src/open-page.js
Normal file
@@ -0,0 +1,25 @@
|
||||
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(() => {});
|
||||
Reference in New Issue
Block a user