Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/macacajs/macaca-puppeteer
Macaca puppeteer driver
https://github.com/macacajs/macaca-puppeteer
headless macaca puppeteer
Last synced: about 1 month ago
JSON representation
Macaca puppeteer driver
- Host: GitHub
- URL: https://github.com/macacajs/macaca-puppeteer
- Owner: macacajs
- License: mit
- Created: 2017-08-17T06:18:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-19T15:22:58.000Z (over 2 years ago)
- Last Synced: 2024-11-11T21:24:45.436Z (about 1 month ago)
- Topics: headless, macaca, puppeteer
- Language: JavaScript
- Homepage: https://macacajs.github.io/guide/versioning.html
- Size: 578 KB
- Stars: 42
- Watchers: 12
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# macaca-puppeteer
---
[![NPM version][npm-image]][npm-url]
[![CI][CI-image]][CI-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![node version][node-image]][node-url][npm-image]: https://img.shields.io/npm/v/macaca-puppeteer.svg
[npm-url]: https://npmjs.org/package/macaca-puppeteer
[CI-image]: https://github.com/macacajs/macaca-puppeteer/actions/workflows/ci.yml/badge.svg
[CI-url]: https://github.com/macacajs/macaca-puppeteer/actions/workflows/ci.yml
[coveralls-image]: https://img.shields.io/coveralls/macacajs/macaca-puppeteer.svg
[coveralls-url]: https://coveralls.io/r/macacajs/macaca-puppeteer?branch=master
[node-image]: https://img.shields.io/badge/node.js-%3E=_8-green.svg
[node-url]: http://nodejs.org/download/> [Puppeteer](//github.com/GoogleChrome/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
```bash
$ npm i macaca-puppeteer -g
```## Usage as module
```javascript
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();
};
```- [sample](//github.com/macaca-sample/sample-nodejs)
- [More API](//macacajs.github.io/macaca-puppeteer/)## Contributors
|[
xudafeng](https://github.com/xudafeng)
|[
zivyangll](https://github.com/zivyangll)
|[
snapre](https://github.com/snapre)
|
| :---: | :---: | :---: |This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Tue Apr 19 2022 23:22:01 GMT+0800`.