We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用npm安装npm i puppeteer。
npm i puppeteer
执行以下代码
const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com'); await page.screenshot({path: 'example.png'}); await browser.close(); })();
报错 Error: Could not find browser revision 768783. Run "npm install" or "yarn install" to download a browser binary.
Error: Could not find browser revision 768783. Run "npm install" or "yarn install" to download a browser binary.
需要手动安装Chromium
下载地址:https://download-chromium.appspot.com/
然后更改代码指向Chromium.app路径
const puppeteer = require('puppeteer') ;(async () => { const browser = await puppeteer.launch({ executablePath: '/Applications/Chromium.app', headless: false }) const page = await browser.newPage() await page.goto('https://example.com') await page.screenshot({ path: 'example.png' }) await browser.close() })()
报错 UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! spawn /Applications/Chromium.app/ EACCES
UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! spawn /Applications/Chromium.app/ EACCES
更改路径 executablePath: '/Applications/Chromium.app/Contents/MacOS/Chromium'
executablePath: '/Applications/Chromium.app/Contents/MacOS/Chromium'
const puppeteer = require('puppeteer') ;(async () => { const browser = await puppeteer.launch({ executablePath: '/Applications/Chromium.app/Contents/MacOS/Chromium', headless: false }) const page = await browser.newPage() await page.goto('https://example.com') await page.screenshot({ path: 'example.png' }) await browser.close() })()
puppeteer新手遇到的坑
The text was updated successfully, but these errors were encountered:
No branches or pull requests
安装puppeteer踩坑
使用npm安装
npm i puppeteer
。执行以下代码
报错
Error: Could not find browser revision 768783. Run "npm install" or "yarn install" to download a browser binary.
需要手动安装Chromium
下载地址:https://download-chromium.appspot.com/
然后更改代码指向Chromium.app路径
报错
UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! spawn /Applications/Chromium.app/ EACCES
更改路径
executablePath: '/Applications/Chromium.app/Contents/MacOS/Chromium'
参考的解决方案
puppeteer新手遇到的坑
The text was updated successfully, but these errors were encountered: