Hi,
I was wondering if it is possible to get the complete rendered html for a given website.
Thanks.
You can get the root node after the html is rendered and use it to get the html.
Chrome.Run(ctx, cdp.ActionFunc(func(ctxt context.Context, h cdptypes.Handler) error {
var err error
root, err := h.GetRoot(ctxt)
if err != nil {
log.Errorf("Failed to get root node: %v", err)
return err
}
html, err = dom.GetOuterHTML(root.NodeID).Do(ctxt, h)
if err != nil {
log.Errorf("Failed to get outer HTML: %v", err)
return err
}
log.Debugf("Outer HTML: %#v", html)
return nil
}))
As @af608 pointed out, this is the proper way to get the outer HTML. I'll make a point to add a high-level action to get the inner and outer HTML of an element, however.
OuterHTML and InnerHTML high level actions have been added in 1a35cceeae17ddbf999b586d4e1770963eedc710.
Most helpful comment
You can get the root node after the html is rendered and use it to get the html.