Hello,
i am wondering if it is somehow possible to get the page source (after javascript has been executed) as HTML (like a browser would show it if i inspect a pages source with its developer console).
I know that i can convert a HtmlPage to XML like this:
a given html:
<div> <span id="dynamic"></span> <script> document.querySelector('#dynamic').innerHTML = "<span>dynamically added</span>"; </script> </div>
// kotlin example to parse HTML as string to HtmlPage object val rendered: HtmlPage = WebClient(BrowserVersion.BEST_SUPPORTED).loadHtmlCodeIntoCurrentWindow(htmlFromAboveAsString) // convert HtmlPage object to XML as string and print it to console println(rendered.asXml())
which will lead to the following output:
<html> <head></head> <body> <div> <span id="dynamic"><span>dynamically added</span></span> <script> document.querySelector('#dynamic').innerHTML = "<span>dynamically added</span>"; </script> </div> </body> </html>
Actual Question:
Is it possible to get a rendered html version as string instead of a html that has been converted to xml?