亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么 ProxyServer 無法在 chromedp GO 上運行

為什么 ProxyServer 無法在 chromedp GO 上運行

Go
拉丁的傳說 2023-07-10 16:33:06
我想在 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


查看完整回答
反對 回復 2023-07-10
  • 1 回答
  • 0 關注
  • 271 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號