chromedp.run error handling

This commit is contained in:
Antoni Sawicki 2019-05-31 00:41:46 -07:00
parent 0ae49044c2
commit 416490289d
1 changed files with 7 additions and 1 deletions

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)
// Run ChromeDP Magic
chromedp.Run(ctx,
err := chromedp.Run(ctx,
emulation.SetDeviceMetricsOverride(w, h, s, false),
chromedp.Navigate(gourl),
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.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))
// Process Screenshot Image