Puppeteer node浏览器自动化工具

仓库
https://github.com/puppeteer/puppeteer

中文文档

  • 官方
    https://zhaoqize.github.io/puppeteer-api-zh_CN/#/

  • 第三方
    https://puppeteer-china.github.io/

  • 三方工具
    • jquery api的使用puppeteer-jquery
      https://www.npmjs.com/package/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 

await page.jQuery('body').append(`

Title

`); // 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() ; })()

你可能感兴趣的:(Puppeteer node浏览器自动化工具)