1

I need to parse a webpage that is generated by JavaScript. So, I need to know if there is a way of capture the HTML generated by a browser with PHP.

I have seen examples of capturing the print screen of a wep page generated by the browser. It is possible to capture the HTML?

Best Regards,

André
  • 24,706
  • 43
  • 121
  • 178

1 Answers1

4

you can't capture it since javascript is processed by the client browser, not the server,

a way to do what you want can be to insert javascript code in page to send the entire html to the server:

if you use jquery you can do it with something like this:

var htmlCode = $("body").html();
$.post("recorder.php", { html: htmlCode } );
  • You can do it that way, but it is not pure server side (you will still have to manually open page in browser). – Dejan Marjanović Mar 27 '11 at 01:31
  • true, but you can use a program that opens a page, and waits till it loads, and the just let it run for every page you need –  Mar 27 '11 at 01:32
  • I am saying you can't use something like **echo $crawler->parse($url);**, meaning no client side at all, It can be done to some extent using server side only (manually). – Dejan Marjanović Mar 27 '11 at 01:47