Skip to main content

Go (chromedp)

Go library chromedp is supported. All you need to do is to use the RemoteAllocator to connect to BrowserCloud API, so it's just the same like your any local application launch.

To begin with, go over the example of navigating to the Example.com site and getting the title that are given below:

Example

package main

import (
"context"
"flag"
"github.com/chromedp/chromedp"
"log"
)

func main() {
devtoolsWsURL := flag.String("devtools-ws-url", "wss://chrome-v2.browsercloud.io?token=API_TOKEN", "DevTools WebSsocket URL")
flag.Parse()

allocatorContext, cancel := chromedp.NewRemoteAllocator(context.Background(), *devtoolsWsURL, chromedp.NoModifyURL)
defer cancel()

ctx, cancel := chromedp.NewContext(allocatorContext)
defer cancel()

var title string
if err := chromedp.Run(ctx,
chromedp.Navigate("https://browsercloud.io/"),
chromedp.Title(&title),
); err != nil {
log.Fatalf("Failed getting title of example.com: %v", err)
}

log.Println("Got title of:", title)
}

You can use Go along with BrowserCloud despite the Title logoff from the Example website.

In case of any questions feel free to contact us: support@browsercloud.io