macaca-puppeteer
v13.0.0
Published
macaca puppeteer driver
Downloads
17
Readme
macaca-puppeteer
Puppeteer is a Node library which provides a high-level API to control headless Chrome over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome. Macaca Puppeteer is a long-term maintained browser driver as a candidate for Macaca Electron driver.
Installment
$ npm i macaca-puppeteer -g
Usage as module
const fs = require('fs');
const path = require('path');
const Puppeteer = require('macaca-puppeteer');
const puppeteer = new Puppeteer();
async function() {
/**
default options
{
headless: false,
x: 0,
y: 0,
width: 800,
height: 600,
userAgent: 'userAgent string'
}
*/
await puppeteer.startDevice({
headless: true // in silence
});
await puppeteer.maximize();
await puppeteer.setWindowSize(null, 500, 500);
await puppeteer.get('https://www.baidu.com');
const imgData = await puppeteer.getScreenshot();
const img = new Buffer(imgData, 'base64');
const p = path.join(__dirname, '..', 'screenshot.png')
fs.writeFileSync(p, img.toString('binary'), 'binary');
console.log(`screenshot: ${p}`);
await puppeteer.stopDevice();
};
Contributors
|xudafeng|zivyangll| | :---: | :---: |
This project follows the git-contributor spec, auto updated at Fri Nov 19 2021 19:26:42 GMT+0800
.