This commit is contained in:
wenpeng 2024-08-01 17:30:36 +08:00
parent 9a9b4646ca
commit b3f96ddddd
2 changed files with 17 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import { setLocalStorage } from './utils/userUtils.js';
import { getDate, cleanType, changeTimeDimension } from './utils/businessDataUtil.js';
(async () => {
const browser = await launch({ headless: false, args: [`--window-size=1920,1080`], defaultViewport: { width: 1920, height: 1080 } });
const browser = await launch({ headless: true, args: [`--window-size=1920,1080`], defaultViewport: { width: 1920, height: 1080 } });
const page = await browser.newPage();
setLocalStorage(page, '.\\data\\user.json');
await page.goto('https://dev-dmp.meiguanjia.net/report/businessData');
@ -24,7 +24,7 @@ import { getDate, cleanType, changeTimeDimension } from './utils/businessDataUti
fs.writeFileSync(file, '', 'utf-8');
await cleanType(page, '.arco-picker-start-time', '2024-07');
await cleanType(page, '.arco-picker-start-time', '2024-05');
await getDate(page, fs, file);
console.log('========');

View File

@ -1,3 +1,9 @@
/**
*
* @param {Page} page
* @param {fs} fs
* @param {String} file 存储文件位置
*/
export async function getDate(page, fs, file) {
const its = new Map();
@ -35,7 +41,15 @@ export async function getDate(page, fs, file) {
console.log('#label-content not found in the iframe');
}
const importStorage = JSON.stringify(Array.from(its), null, 2);
const convert = {};
for (const [key, value] of its) {
convert[key] = value;
}
console.log(convert);
const importStorage = JSON.stringify(convert, null, 2);
fs.appendFileSync(file, importStorage, 'utf-8');
}