11

I want to get the source code of a HTML page, but it has a JS script that loads the data dynamically and attaches the received content to the page.

I am using jsoup to parse HTML, but it only returns the content before the JS execution, so I do not receive the dynamically loaded data.

How can I get the source code after the script execution using any framework, cli, etc?

FilipeFalcao
  • 148
  • 6

2 Answers2

0

You can use;

$(window).load();

Which will wait until the page is loaded.

Another option:

function whenAvailable(name, callback) {
var interval = 10; // ms
window.setTimeout(function() {
    if (window[name]) {
        callback(window[name]);
    } else {
        window.setTimeout(arguments.callee, interval);
    }
}, interval);
}

And use it like this:

whenAvailable("jsLoadFunction", function(t) {
// do something
});
yjs
  • 692
  • 3
  • 11
-1

You can use load event of window. Example :

window.onload = function(){
        /*Parse Html*/
}
Majar K
  • 34
  • 7