1234567891011121314151617181920212223242526272829303132333435363738 |
- package lxrod
- import (
- "context"
- "github.com/go-rod/rod"
- "github.com/go-rod/rod/lib/devices"
- "github.com/go-rod/rod/lib/launcher"
- )
- // NewLauncher 创建一个新的 rod 浏览器启动器
- func NewLauncher(ctx context.Context) *launcher.Launcher {
- return launcher.New().Context(ctx).Set("window-size", "1600,900").Headless(false)
- }
- // NewEdgeBrowser 创建一个由 rod chromium 模拟的 Edge 浏览器
- func NewEdgeBrowser(ctx context.Context, u string) *rod.Browser {
- return rod.New().Context(ctx).DefaultDevice(EdgeLandscape).ControlURL(u)
- }
- // EdgeLandscape device.
- var EdgeLandscape = devices.Device{
- Title: "Edge Laptop with HiDPI screen",
- Capabilities: []string{},
- UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
- AcceptLanguage: "en",
- Screen: devices.Screen{
- DevicePixelRatio: 2,
- Horizontal: devices.ScreenSize{
- Width: 1600,
- Height: 900,
- },
- Vertical: devices.ScreenSize{
- Width: 900,
- Height: 1600,
- },
- },
- }.Landscape()
|