go - headless browser using chromedp from scraping aliexpress - Stack Overflow

admin2025-04-16  5

when i use this code to navigate a root link "/?language=en&region=US" using chromedp. Aliexpress redirect me to the arabic page.

i need to get to directly to the english page

this is the code that i'm using :

err := chromedp.Run(ctx,
    chromedp.EmulateViewport(1920, 1980),
    // Navigate to AliExpress with English language and US region
    chromedp.Navigate(`/?language=en&region=US`),
    chromedp.WaitVisible(`body`, chromedp.ByQuery),
    chromedp.Sleep(5*time.Second), // Wait for the page to fully load
    // Extract all links with their text and href
    chromedp.Evaluate(`
        JSON.stringify(
            Array.from(document.querySelectorAll('a')).map(a => ({
                text: a.textContent.trim(),
                href: a.href
            }))
        )
    `, &links),
)
if err != nil {
    log.Fatal(err)
}

if there is away to add some header first please help me

转载请注明原文地址:http://anycun.com/QandA/1744784728a87583.html