playwright-community / playwright-go

Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
https://playwright-community.github.io/playwright-go/
MIT License
1.94k stars 144 forks source link

unable goto ins page #452

Closed twolao closed 2 months ago

twolao commented 2 months ago

Environments

Bug description unable access ins, for example: https://www.instagram.com/musickillskate/

WX20240426-111104@2x

how to resolve this problem?

To Reproduce Please provide a mini reproduction rather than just a description. For example:

package main

import (
    "fmt"
    "log"

    "github.com/playwright-community/playwright-go"
)

func main() {
    pw, err := playwright.Run()
    if err != nil {
        log.Fatalf("could not start playwright: %v", err)
    }
    defer pw.Stop()

    option := playwright.BrowserTypeLaunchOptions{
        Headless: playwright.Bool(false),
    }
    browser, err := pw.Firefox.Launch(option)
    if err != nil {
        log.Fatalf("could not launch browser: %v", err)
    }
    defer browser.Close()

    context, err := browser.NewContext(playwright.BrowserNewContextOptions{
        Locale:     playwright.String("en-US"),
        TimezoneId: playwright.String("Europe/Berlin"),
    })
    if err != nil {
        log.Fatalf("could not create browser context: %v", err)
    }
    defer context.Close()
    context.SetExtraHTTPHeaders(map[string]string{
            "Accept-Language": "en-US;q=0.3,en;q=0.2",
        }) 

    page, err := context.NewPage()
    if err != nil {
        log.Fatalf("could not create page: %v", err)
    }

    if _, err := page.Goto("https://www.instagram.com/musickillskate/"); err != nil {
        log.Fatalf("could not go to: %v", err)
    }

    fmt.Println("Press ENTER to continue...")
    fmt.Scanln()

    if err := page.Close(); err != nil {
        log.Fatalf("could not close page: %v", err)
    }
}

Additional context Add any other context about the problem here.