-1

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.ProxyServer("http://username:password@proxyserver.com: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
        }))

Tried this as well but not working.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
SAJIKUMAR j s
  • 27
  • 1
  • 4

1 Answers1

2

Check this answer

o := append(chromedp.DefaultExecAllocatorOptions[:],
  //... any options here
  chromedp.ProxyServer("http://username:password@proxyserver.com:31280"), 
)
Vishnu V
  • 382
  • 5
  • 16