初始化项目
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const puppeteer = require('puppeteer-core');
|
||||
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: '/usr/bin/google-chrome-stable',
|
||||
args: ['--no-sandbox'],
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
const url = process.argv[2];
|
||||
|
||||
// 打开指定的页面,并等待网络请求结束
|
||||
await page.goto(url, { waitUntil: 'networkidle0' });
|
||||
|
||||
try {
|
||||
// 等待 class="SQCodeSuccess" 的元素出现,超时时间为60秒
|
||||
await page.waitForSelector('.SQCodeSuccess', { timeout: 60000 });
|
||||
|
||||
// 获取元素的 src 属性
|
||||
const src = await page.$eval('.SQCodeSuccess', el => el.getAttribute('src'));
|
||||
// console.log('SRC Attribute:', src);
|
||||
console.log(src);
|
||||
} catch (e) {
|
||||
// console.error('Error:', e);
|
||||
console.error('');
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
Reference in New Issue
Block a user