I am trying to find a PHP script (or a script in a different language) that after passing a URL, it takes a screenshot of the website for that URL. So for example if I pass
You can use browsershots.org service or litmusapp.com. Both of these will generate screenshot of a page. You can then download the screenshot and use it in a way you need to.
Something like Litmus?
Browsershots normally has their backend source code available, but as of this answer, it appears to be offline at the moment. There is an outdated mirror on Github which you can look at.
Start a Browser (like system("firefox [url]")), run a screengrabber for that window and save the image somewhere.
Since the output is always depending on the render engine used it is not possible by using php alone.
Other option would be to embed a rendering engine (Gecko or similar) into your php script.