1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| const puppeteer = require('puppeteer'); const request = require('request'); const fs = require('fs');
(async()=>{ const browser = await puppeteer.launch({ executablePath: 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe', headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'], }); try { const page = await browser.newPage(); await page.goto('https://www.itingshu.net/play/19307_1_92359.html',{ waitUntil: 'networkidle0' }) await page.screenshot({path: 'bilibili.png'}); await page.pdf({path: 'bilibili.pdf'}); const src = await page.evaluate(() =>{ return document.getElementById('jp_audio_0').getAttribute('src'); }) console.log(src); let path = __dirname + `/遮天/test.m4a` const stream = fs.createWriteStream(path); request(src).pipe(stream).on('close', () => { console.log('当前完成:'); }); } catch (error) { console.error(error) } finally{ await browser.close(); } })()
|