I need some piece of PHP script (or function) that can load a complete webpage including AJAX parts and images, I mean by giving the URL it returns me a complete HTML.

Up to now i have used "simple_html_dom" and some Curl based functions but none of these work for AJAX parts.

For this to work, the library probably has to simulate a browser with JavaScript, load the page and wait for all elements to load/transform, before taking the HTML.

It must be free, ideally open source.

  • What do you mean can load a complete web page? cURL will easily return you all the HTML content. If you really want to make a perfect copy with scripts and css running perfectly the easiest way might simply be to make an iframe.
    – Huey
    Apr 14, 2015 at 13:08
  • I mean some script(or program) that can simulate browser and send javascript requests and get all the html code and then return all of the gathered HTML.
    – Hossein
    Apr 15, 2015 at 11:02

2 Answers 2


I've used the PhantomJS headless browser, and it's great for doing this sort of thing - everything a browser does is provided to a scripting language instead of a GUI. I suspect much of the reason it works so well is that it uses the same V8 JavaScript-engine as Chrome... shame that's the wrong scripting-language for you...

I notice someone has created some PHP bindings to the Phantom API in a package called PHP PhantomJS. I haven't used it because I've never needed this functionality from PHP, but that's certainly the route I'd be looking into going down if I wanted to used a headless browser within PHP.


To accomplish this I would use Snoopy

Snoopy is a PHP class that simulates a web browser. It automates the task of retrieving web page content and posting forms, for example.

To get started, I would check out This Guide, please tell me if it works out

  • 1
    Snnopy looks like 37KB of nicely laid-out PHP code to me? I've only had a quick glance, but I'm pretty sure it can't run JavaScript, unfortunately.
    – Antony
    Oct 25, 2015 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.