bank.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package lxrod
  2. import (
  3. "context"
  4. "github.com/go-rod/rod"
  5. "github.com/go-rod/rod/lib/devices"
  6. "github.com/go-rod/rod/lib/launcher"
  7. )
  8. // NewLauncher 创建一个新的 rod 浏览器启动器
  9. func NewLauncher(ctx context.Context) *launcher.Launcher {
  10. return launcher.New().Context(ctx).Set("window-size", "1600,900").Headless(false)
  11. }
  12. // NewEdgeBrowser 创建一个由 rod chromium 模拟的 Edge 浏览器
  13. func NewEdgeBrowser(ctx context.Context, u string) *rod.Browser {
  14. return rod.New().Context(ctx).DefaultDevice(EdgeLandscape).ControlURL(u)
  15. }
  16. // EdgeLandscape device.
  17. var EdgeLandscape = devices.Device{
  18. Title: "Edge Laptop with HiDPI screen",
  19. Capabilities: []string{},
  20. 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",
  21. AcceptLanguage: "en",
  22. Screen: devices.Screen{
  23. DevicePixelRatio: 2,
  24. Horizontal: devices.ScreenSize{
  25. Width: 1600,
  26. Height: 900,
  27. },
  28. Vertical: devices.ScreenSize{
  29. Width: 900,
  30. Height: 1600,
  31. },
  32. },
  33. }.Landscape()