go – How to us proxy with chromedp-ThrowExceptions

Exception or error:

I want to take screenshot of (thousands of pages) of website like Amazon. I tried some code but getting captcha or traffic error in screenshot. So I want to add proxy with chromedp.

ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
        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

Tried this as well but not working.

How to solve:

Check this answer

o := append(chromedp.DefaultExecAllocatorOptions[:],
  //... any options here

Leave a Reply

Your email address will not be published. Required fields are marked *