項(xiàng)目地址:https://github.com/checkly/puppeteer-recorder
官網(wǎng)插件描述:
Chrome extension for recording browser interaction and generating Puppeteer scripts
Puppeteer recorder is a Chrome extension that records your browser interactions and generates a Puppeteer script.
Writing Puppeteer scripts for scraping, testing and monitoring can be tricky. A recorder / code generator can be helpful. This extension has the following features:
- Record clicks, input events etc.
- Pause the recording when navigating.
- Monitor recorded events.
- Export to Puppeteer code.
- Tweak the settings of the generated code.
This extension is actively developed. More events and actions will be added in later versions.
安裝
進(jìn)入Chrome web store
查找puppeteer recorder

add to chrome

錄制
打開(kāi)開(kāi)始錄制

執(zhí)行
在bing中輸入puppeteer,點(diǎn)擊search,點(diǎn)擊第一個(gè)鏈接
停止

錄制的腳本如下:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.setViewport({ width: 991, height: 618 })
await page.goto('https://cn.bing.com/?scope=web&FORM=QBRE')
await page.waitForSelector('#sbox > .search_controls > #sb_form > .b_searchboxForm > #sb_form_go')
await page.click('#sbox > .search_controls > #sb_form > .b_searchboxForm > #sb_form_go')
const navigationPromise = page.waitForNavigation()
await navigationPromise
await page.waitForSelector('.b_algo:nth-child(1) > .b_title > h2 > a > strong')
await page.click('.b_algo:nth-child(1) > .b_title > h2 > a > strong')
await navigationPromise
await browser.close()
})()