Documentation
¶
Overview ¶
Command structeval is a chromedp example demonstrating how to evaluate JavaScript into typed Go values. The type parameter of chromedp.Evaluate decides how the result is read. The program loads a local page that holds a JavaScript object with nested data, and it reads parts of the object as a struct, a slice of structs, a map, a number, a decimal number and a boolean. It shows the Go errors for a JavaScript exception, for a result of undefined or null, and for a result of the wrong type. It also shows how to wait for a promise with an option for Evaluate. It starts a local server and needs no internet. Use -v to print the protocol messages, -visible to show the browser window and leave it open, and -visible-on-terminal to draw the page in the terminal with terminal graphics.