我想截取亞馬遜等網站(數千頁)的屏幕截圖。我嘗試了一些代碼,但在屏幕截圖中出現了驗證碼或流量錯誤。所以我想用 chromedp 添加代理。ctx, cancel := chromedp.NewContext(context.Background())defer cancel()chromedp.ProxyServer("http://username:[email protected]:31280")chromedp.Run(ctx, chromedp.Navigate("http://wtfismyip.com"), chromedp.Sleep(3*time.Second), chromedp.ActionFunc(func(ctxt context.Context) error { _, _, contentRect, err := page.GetLayoutMetrics().Do(ctxt) v := page.Viewport{ X: contentRect.X, Y: contentRect.Y, Width: contentRect.Width, Height: contentRect.Height, Scale: 1, } buf, err := page.CaptureScreenshot().WithClip(&v).Do(ctxt) log.Printf("Write %v", "/tmp/ss.png") ioutil.WriteFile("/tmp/ss.png", buf, 0644) return err }))也嘗試過這個,但不起作用。
1 回答

慕容708150
TA貢獻1831條經驗 獲得超4個贊
o := append(chromedp.DefaultExecAllocatorOptions[:],
? //... any options here
? chromedp.ProxyServer("http://username:[email protected]:31280"),?
)
- 1 回答
- 0 關注
- 464 瀏覽
添加回答
舉報
0/150
提交
取消