go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5.39k stars 353 forks source link

"Page" doesn't work in vivaldi browser. #1143

Open aca opened 1 day ago

aca commented 1 day ago

Another chromium based browser vivaldi doesn't seem to work with rod. I haven't tested all, but playwright-py can navigate pages. Is there a way to use vivaldi with go-rod?

package main

import (
    "encoding/json"
    "log"
    "net/http"

    "github.com/go-rod/rod"
)

// run browser (macos)
// open -a Vivaldi --args --remote-debugging-port=9222

func main() {
    wsurl := getWebsocketDebuggerUrl("http://localhost:9222")
    log.Println(wsurl)
    rod.New().ControlURL(wsurl).MustConnect().MustPage("https://github.com")
}

type VersionResponse struct {
    WebSocketDebuggerUrl string `json:"webSocketDebuggerUrl"`
}

func getWebsocketDebuggerUrl(url string) string {
    resp, err := http.Get(url + "/json/version")
    if err != nil {
        log.Fatalf("Failed to make request: %v", err)
    }
    defer resp.Body.Close()
    var versionResp VersionResponse
    err = json.NewDecoder(resp.Body).Decode(&versionResp)
    if err != nil {
        log.Fatalf("Failed to decode JSON: %v", err)
    }
    return versionResp.WebSocketDebuggerUrl
}

2024/11/13 13:27:59 ws://localhost:9222/devtools/browser/0244adc3-594d-42df-9f53-dcb40a9880fe
panic: EOF

goroutine 1 [running]:
github.com/go-rod/rod/lib/utils.init.func2({0x102de9c40?, 0x10311b670?})
        /Users/x/pkg/mod/github.com/go-rod/rod@v0.116.2/lib/utils/utils.go:68 +0x24
main.main.New.(*Browser).WithPanic.genE.func2({0x14000288590?, 0x102a5bf9d?, 0x12?})
        /Users/x/pkg/mod/github.com/go-rod/rod@v0.116.2/must.go:36 +0x70
github.com/go-rod/rod.(*Browser).MustPage(0x14000224360, {0x140000dff08?, 0x2?, 0x140000dff18?})
        /Users/x/pkg/mod/github.com/go-rod/rod@v0.116.2/must.go:71 +0xec
main.main()
        /Users/x/src/scratch/2024/11/20241113T131333/rod/main.go:17 +0x2fc
exit status 2
github-actions[bot] commented 1 day ago

Please add a valid Rod Version: v0.0.0 to your issue. Current version is v0.116.2

Please fix the format of your markdown:

3 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
40 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
41 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
41 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]

generated by check-issue

ysmood commented 15 hours ago

better to enable cdp log to see what's goes wrong:

go run main.go -rod=cdp