网络日志记录
¥Network logging
默认情况下,Puppeteer 监听所有网络请求和响应,并在页面上触发网络事件。
¥By default, Puppeteer listens for all network requests and responses and emits network events on the page.
const page = await browser.newPage();
page.on('request', request => {
console.log(request.url());
});
page.on('response', response => {
console.log(response.url());
});