29 lines
881 B
JavaScript
29 lines
881 B
JavaScript
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();
|
|
})();
|