macaca-puppeteer
macaca puppeteer driver
Last updated 2 months ago by xudafeng .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install macaca-puppeteer 
SYNC missed versions from official npm registry.

macaca-puppeteer

Gitter Chat NPM version build status Test coverage node version

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.

Installment

$ npm i macaca-puppeteer -g

Usage as module


const co = require('co');
const fs = require('fs');
const path = require('path');
const Puppeteer = require('macaca-puppeteer');

const puppeteer = new Puppeteer();

co(function *() {
  /**
    default options
    {
      show: true,
      x: 0,
      y: 0,
      width: 800,
      height: 600,
      userAgent: 'userAgent string'
    }
  */
  yield puppeteer.startDevice({
    show: false // in silence
  });

  yield puppeteer.maximize();
  yield puppeteer.setWindowSize(null, 500, 500);
  yield puppeteer.get('https://www.baidu.com');
  const imgData = yield 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}`);

  yield puppeteer.stopDevice();
});
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 6
Last Day 1
Last Week 3
Last Month 8
Dependencies (7)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |