go-rod 自定义启动

 

 

 

u := launcher.New().
        Headless(false).
        //Devtools(true).
        Bin("E:\\Chrome-bin\\chrome.exe").MustLaunch()

    browser := rod.New().ControlURL(u).
        //Trace(true). // log useful info about what rod is doing
        //Timeout(60 * time.Second).
        //SlowMotion(2 * time.Second). //SlowMotion是一个调试相关的函数,它在每个操作之间等待2秒,使您更容易检查代码正在做什么。
        MustConnect()
    defer browser.MustClose()

    url := "https://www.xxxxxxx"
    page := stealth.MustPage(browser)
    page.MustWindowMaximize()
    //page.MustWindowFullscreen()
    //page.MustSetWindow(0, 0, 1920, 938)

    router := page.HijackRequests()
    defer router.MustStop()
go router.Run()


    err := rod.Try(func() {
        page.Timeout(60 * time.Second).MustNavigate(url).MustWaitLoad().CancelTimeout()
    })

 

posted @ 2023-02-13 16:16  AngDH  阅读(161)  评论(0编辑  收藏  举报