puppeteer recorder使用說明
專案地址: ofollow,noindex">https://github.com/checkly/puppeteer-recorder
官網外掛描述:
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.
安裝
進入Chrome web store
查詢puppeteer recorder

image.png
add to chrome
新增成功後出現

image.png
錄製
開啟開始錄製

image.png
執行
在bing中輸入puppeteer,點選search,點選第一個連結
停止

image.png
錄製的指令碼如下:
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()
})()