puppeteer调研

Puppeteer Intro

Puppeteer金字塔

"Puppeteer Pyramid"

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

"puppeteer-devtools-protocol"

Puppeteer的使用场景。

"Puppeteer use case"

Demo - screenshot

setup

1
npm i puppeteer --save

demo

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 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)”

暂无数据