Puppeteer 中文文档v25.8.0

Page.setGeolocation() 方法

设置页面的地理位置。

签名

class Page {
  abstract setGeolocation(options: GeolocationOptions): Promise<void>;
}

参数

参数

类型

说明

options

GeolocationOptions

返回值:

Promise<void>

备注

可考虑使用 BrowserContext.overridePermissions() 授予页面读取其地理位置的权限。

示例

await page.setGeolocation({latitude: 59.95, longitude: 30.31667});