标签:pre 算数 有用 sts dom rip layout 执行 rgb
const puppeteer = require(‘puppeteer‘); const fs = require(‘fs‘); puppeteer.launch().then(async browser => { const page = await browser.newPage(); page.on(‘console‘, msg => console.log(msg.text)); await page.exposeFunction(‘readfile‘, async filePath => { return new Promise((resolve, reject) => { fs.readFile(filePath, ‘utf8‘, (err, text) => { if (err) reject(err); else resolve(text); }); }); }); await page.evaluate(async () => { // use window.readfile to read contents of a file const content = await window.readfile(‘/etc/hosts‘); console.log(content); }); await browser.close(); });
标签:pre 算数 有用 sts dom rip layout 执行 rgb
原文地址:https://www.cnblogs.com/absoluteli/p/14295501.html