From 35ea1380cbc65980f1664fb56fd5f5d4762807ef Mon Sep 17 00:00:00 2001 From: rsgltzyd Date: Tue, 23 Jul 2024 22:59:40 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=95=B0=E6=8D=AE=E5=88=86=E6=9E=90?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example2.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 example2.js diff --git a/example2.js b/example2.js new file mode 100644 index 0000000..5ebe102 --- /dev/null +++ b/example2.js @@ -0,0 +1,34 @@ +import { launch } from 'puppeteer'; +import 'dotenv/config.js' + +(async () => { + const browser = await launch({ headless: true, args: [`--window-size=1920,1080`], defaultViewport: { width: 1920, height: 1080 } }); + const page = await browser.newPage(); + await page.goto('https://dev-dmp.meiguanjia.net/login'); + await page.locator('#userName input').fill(process.env.ACCOUNT); + await page.locator('#passWord input').fill(process.env.PASSWORD); + await page.locator('[type="submit"]').click(); + + await page.waitForSelector('.arco-modal', { visible: true }); + await page.locator('.arco-list-content:first-child .role_box').click(); + + await page.waitForSelector('.arco-message .arco-message-content', { visible: true }); + const arcoMessage = await page.$eval('.arco-message .arco-message-content', node => node.innerHTML); + console.log(arcoMessage); + + await page.waitForSelector('.menu-list-second'); + const childElements = await page.$$('.menu-list-second .menu-list-second-item'); + await new Promise(r => setTimeout(r, 1000)); + await childElements[1].click(); + const str = await page.evaluate(node => node.textContent.trim(), childElements[1]); + console.log(str); + + await new Promise(r => setTimeout(r, 1000)); + await page.waitForSelector('.ai_custome'); + const aiCustome = await page.$$('.ai_custome .ai_custome_item'); + for (const e of aiCustome) { + let str = await page.evaluate(element => element.textContent.trim(), e); + console.log(str); + } + await browser.close(); +})(); \ No newline at end of file