最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论