How to output DOM after all javascript loaded?
curl, dom, javascript, phantomjs, php
Solution
Why not:
jQuery(document).ready(function($) {
$.post(
'/your_filename.php',
'html='+$("html").html(),
function(response){
alert(response);
}
);
});
Problem
As title, my question is how to output (lets say save as a text file on server computer or pass the result to some other php function using ajax) all DOM content on a page? I did some homework, I tried curl can just output all DOM content using "curl http://google.ca > dom.txt" However, the this approach will not save contents that Javascript generated, in other words, the javascript code will not run. Another approach is to embed some javascript code into a page and let the page load the website we want to output, then use the javascript code to save all DOM file after everything is loaded. I am not sure if phantom.js can do such job, if yes, then how to? Any body can give a detailed answer on how to achieve this? I am open to any solutions, this program will run on my server to provide service. Thank you in advance.