我想在 chromedp 上使用代理,但代理似乎不起作用,嘗試了 chromedp.ProxyServerctx, 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 }))使用代理后我得到了我的公共 ipeven。沒有錯誤/警告
1 回答

冉冉說
TA貢獻1877條經驗 獲得超1個贊
嘗試這個:
o := append(chromedp.DefaultExecAllocatorOptions[:],
//... any options here
chromedp.ProxyServer("http://username:[email protected]:31280"),
)
cx, cancel := chromedp.NewExecAllocator(context.Background(), o...)
defer cancel()
ctx, cancel := chromedp.NewContext(cx)
defer cancel()
//... the rest of your code
- 1 回答
- 0 關注
- 271 瀏覽
添加回答
舉報
0/150
提交
取消