Puppeteer node浏览器自动化工具

2020-11-25  本文已影响0人  TOPro

中文文档
https://puppeteer-china.github.io/

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

jquery api的使用puppeteer-jquery
https://www.npmjs.com/package/puppeteer-jquery

const $jquery = require("puppeteer-jquery");
const {pageExtend, PageEx} = $jquery;

let browser = await launch({headless: true});
let pageOrg = await browser.newPage();
let page = pageExtand(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()
;
上一篇下一篇

猜你喜欢

热点阅读