仓库
https://github.com/puppeteer/puppeteer
中文文档
- 三方工具
- jquery api的使用puppeteer-jquery
https://www.npmjs.com/package/puppeteer-jquery
- jquery api的使用puppeteer-jquery
# 首次使用修改镜像地址
npm config set puppeteer_download_host=https://npm.taobao.org/mirrors
# 安装
yarn add puppeteer puppeteer-jquery
const puppeteer = require('puppeteer');
const $jquery = require("puppeteer-jquery");
const {pageExtend, PageEx} = $jquery;
(async __=>{
let browser = await puppeteer.launch({headless: false});
let pageOrg = await browser.newPage();
let page = pageExtend(pageOrg);
// append a <H1>
await page.jQuery('body').append(`<h1>Title</h1>`);
// get the H1 value
let title = await page.jQuery('h1').text();
// chain calls
let text = await page.jQuery('body button:last')
.closest('div')
.find('h3')
.css('color', 'yellow')
.parent()
.find(':last')
.text()
;
})()