Yuying Wu

Light
Dark

puppeteer调研

July 10, 2018

Tags:puppeteer

Puppeteer Intro

Puppeteer金字塔

"Puppeteer Pyramid"

无需再通过Chrome的开发协议,写冗长复杂的代码,轻松调用Chrome API。

"puppeteer-devtools-protocol"

Puppeteer的使用场景。

"Puppeteer use case"

Demo - screenshot

setup

npm i puppeteer --save

demo

打开example.com,截屏,生成文件example.png

// screenshot.js
const puppeteer = require('puppeteer');
puppeteer.launch({
headless: false
}).then(async browser => {
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'example.png'});
await browser.close();
});
// run the demo
// node screenshot.js

"screenshot-puppeteer"

Youtube Video: “Intro of Puppeteer - Chrome Dev Summit 2017” “The power of Headless Chrome and browser automation (Google I/O ‘18)”

评论区


Yuying Wu
Yuying Wu 个人博客,文字、代码、照片,记录工作和生活.
你可以在这里关注我:RSSGithub