i'm using chromedp and I want to get the content of a javascript array declared inside a page I scroll
<script>
var title = document.title;
var pages = [{"key1":"value1","key2":1,"external":1},{"key1":"value2", "key2":9}];
</script>
I tried
var res *runtime.RemoteObject
if err := c.Run(ctxt, chromedp.EvaluateAsDevTools("pages", &res)); err != nil {
return fmt.Errorf("could not evaluate page : %v", err)
}
json_byte, _ := res.MarshalJSON()
var out bytes.Buffer
_ = json.Indent(&out, json_byte, "", "\t")
log.Printf("pages %s ", out.String())
but it gives me something like
2019/03/08 13:12:52 pages {
"type": "object",
"subtype": "array",
"className": "Array",
"description": "Array(22)",
"objectId": "{\"injectedScriptId\":441,\"id\":1}"
}
I want be able to get the actual content of the variable pages (keys and values). What is the way to get this content ?