I-chromedp.ProxyServer iyinketho yokuqalisa isiphequluli. Yisebenzise ku-allocator edala inqubo ye-Chromium:

opts := append(chromedp.DefaultExecAllocatorOptions[:],
    chromedp.ProxyServer("http://proxy.example:8080"),
)
allocCtx, cancelAllocator := chromedp.NewExecAllocator(
    context.Background(), opts...,
)
defer cancelAllocator()

tabCtx, cancelTab := chromedp.NewContext(allocCtx)
defer cancelTab()
err := chromedp.Run(tabCtx,
    chromedp.Navigate("https://www.example.com/"),
)

Ikhodi ingeyomsebenzi okhona wohlelo lokusebenza, nokusingathwa kwamaphutha okuvamile kwe-err. I-NewContext ithola i-allocator ku-allocCtx. I-context eyakhiwe kusuka komunye umzali ingakha isiphequluli esihlukile ngaphandle kwaleyo nketho.

I-URL ye-proxy ikhomba isilaleli se-HTTP; abangeneleli bomphakathi batholakala kuhlu lwe-proxy le-HTTP; ikhasi lihlala liyindawo ye-HTTPS. I-ProxyServer ihambisana nefulegi ye---proxy-server ye-Chromium, hhayi ukulungiselelwa kwe-proxy kwe-net/http kwe-Go.

I-Chromium ayikwamukeli igama lomsebenzisi neliphasiwedi afakwe ku-URL ye-proxy yokwenziwa ngesandla. I-endpoint eqinisekisiwe idinga ukuqinisekiswa kwesiphequluli okusekelwayo noma ilungiselelo lomlamuli; ukwengeza i-user:password kulefulegi akulingani nokuqinisekiswa kwe-URL kumklami we-HTTP. Ukugeleza kwemicimbi yokuqinisekisa ye-CDP ku-Chrome kungenye yezindlela ezisekelwayo zokusingatha inselele ye-proxy ehlosiwe.

Gcina i-allocator iphila kuze kuqede umsebenzi wesiphequluli. Ukukhanselwa kwayo nakho kuyingxenye yokuhlanza inqubo, kuyilapho ukukhanselwa kwethebhu kukhawulela i-context yesiphequluli ehlobene.

Izihloko ezihlobene