easy-puppeteer-html
puppeteer prerender html
Last updated 5 years ago by hubcarl .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install easy-puppeteer-html 
SYNC missed versions from official npm registry.

easy-puppeteer-html

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Capture HTML Content By Puppeteer

Install

npm install easy-puppeteer-html --save

Usage

const puppeteer = require('easy-puppeteer-html');
const puppeteer.capture({
  url: 'http://49.233.172.37:7001/csr',
  selector: '#app',
  waitSelector: '#app',
  beforeEvaluate: async (browser, page) => {
    await page.setUserAgent('Mozilla/5.0 (Linux; U; Android 9; en-US) Chrome/57.0.2987.108 UCBrowser/12.12.5.1189 Mobile');
  },
  afterEvaluate: async (browser, page, html) => {
    return html;
  }
}).then(html => {
  console.log(html);
});

Configuration

PuppeteerHtmlPrerenderPlugin options:

  • url - prefetch render url
  • filepath - need prerender dist file path, prerender content will inject into the file
  • selector { optional } - fetch selector element html. if not exist, will return all html.
  • selectorOuterHTML { optional, default: true } - return selector self node content.
  • waitSelector { optional } - fetch selector element html until waiting selector element exist, the config can get the client render mode html content.
  • base64 { optional, default: false } - img with class="base64" is automatically converted to base64
  • debug { optional, default: false } - print puppeteer execute cost and key info
  • beforeEvaluate { optional } - before evaluate fetch hook
  • afterEvaluate { optional } - after evaluate fetch hook

License

MIT

Current Tags

  • 1.0.2                                ...           latest (5 years ago)

3 Versions

  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 1
Dependencies (3)
Dev Dependencies (7)

Copyright 2013 - present © cnpmjs.org | Home |