Puppeteer Network Stats
Attach to a puppeteer page and collect network request stats.
Install
npm install puppeteer-network-stats
Usage
Example below:
-
captures data for all requests
-
request URLs based on the
Network.requestWillBeSent
event -
response status based on the
Network.responseReceived
event -
all event data is merged based on request ids
const PuppeteerNetworkStats = ; const config = url status; const networkStats = config; // const browser = await puppeteer.launch();// const page = browser.newPage(); await networkStats; // creates CDP session, registers listeners // await page.goto(url); networkStats; // gives you an map of all request data by id networkStats; // clears all captured requests await networkStats; // detaches CDP session
A similar configuration allows capturing data from any Network.* events.
As an example for debugging we can just log all event data easily:
const config = 'requestWillBeSent' 'requestServedFromCache' 'loadingFinished' 'loadingFailed' 'responseReceived'