Page.screencast() 方法
🌐 Page.screencast() method
截取此页面的屏幕录制。
🌐 Captures a screencast of this page.
语法
🌐 Signature
class Page {
screencast(options?: Readonly<ScreencastOptions>): Promise<ScreenRecorder>;
}
参数
🌐 Parameters
范围 🌐 Parameter | 类型 🌐 Type | 描述 🌐 Description |
|---|---|---|
options | Readonly<ScreencastOptions> | (可选) 配置屏幕录像行为。 🌐 (Optional) Configures screencast behavior. |
返回:
Promise<ScreenRecorder>
附注
🌐 Remarks
默认情况下,所有录音将使用 VP9 视频编解码器的 WebM 格式,帧率为 30 FPS。
🌐 By default, all recordings will be WebM format using the VP9 video codec, with a frame rate of 30 FPS.
你的系统中必须安装 ffmpeg。
🌐 You must have ffmpeg installed on your system.
示例
🌐 Example
正在录制 页面:
🌐 Recording a page:
import puppeteer from 'puppeteer';
// Launch a browser
const browser = await puppeteer.launch();
// Create a new page
const page = await browser.newPage();
// Go to your site.
await page.goto("https://www.example.com");
// Start recording.
const recorder = await page.screencast({path: 'recording.webm'});
// Do something.
// Stop recording.
await recorder.stop();
browser.close();