chromedp.run error handling

This commit is contained in:
Antoni Sawicki 2019-05-31 00:41:46 -07:00
parent 0ae49044c2
commit 416490289d

8
wrp.go
View File

@ -106,7 +106,7 @@ func capture(gourl string, w int64, h int64, s float64, y int64, out http.Respon
log.Printf("Processing Caputure Request for %s\n", gourl) log.Printf("Processing Caputure Request for %s\n", gourl)
// Run ChromeDP Magic // Run ChromeDP Magic
chromedp.Run(ctx, err := chromedp.Run(ctx,
emulation.SetDeviceMetricsOverride(w, h, s, false), emulation.SetDeviceMetricsOverride(w, h, s, false),
chromedp.Navigate(gourl), chromedp.Navigate(gourl),
chromedp.Evaluate(fmt.Sprintf("window.scrollTo(0, %d);", y), &res), chromedp.Evaluate(fmt.Sprintf("window.scrollTo(0, %d);", y), &res),
@ -115,6 +115,12 @@ func capture(gourl string, w int64, h int64, s float64, y int64, out http.Respon
chromedp.Location(&loc), chromedp.Location(&loc),
chromedp.Nodes("a", &nodes, chromedp.ByQueryAll)) chromedp.Nodes("a", &nodes, chromedp.ByQueryAll))
if err != nil {
log.Printf("%s", err)
fmt.Fprintf(out, "<BR>%s<BR>", err)
return
}
log.Printf("Landed on: %s, Nodes: %d\n", loc, len(nodes)) log.Printf("Landed on: %s, Nodes: %d\n", loc, len(nodes))
// Process Screenshot Image // Process Screenshot Image