0

I want to get a screenshot of a website stored in a variable as a PNG/JPG file with any random name. I know there's a function in windows server but is there anything on a linux server?

Moreover, I just want the screenshot, at any cost. So is there any other and simplest way round to get a screenshot of a site.

Please note: My file would be .php so it should be something compatible.

Maybe I can get something like:

<img src='/screenshots/script.asp?url=google.com' />

Thank you!

mehulmpt
  • 15,861
  • 12
  • 48
  • 88

1 Answers1

0

It is not obvious at all.

You need to install some browser engine on your server, than run it with a specified url, set it's output to some kind of virtual monitor and then capture a screenshot from it.

Read more here. To use from PHP, you'll need exec() function (be careful - it may present a security threat!) and than wait until the screenshot is done.

Community
  • 1
  • 1
Cruel_Crow
  • 359
  • 3
  • 15
  • That's why I'm asking. Is there any alternative to PHP to get a screenshot? – mehulmpt Apr 06 '14 at 13:20
  • Isn't there any way to achieve the following: URL -> iFrame -> Screenshot -> Save on server? – mehulmpt Apr 06 '14 at 13:22
  • What do you mean by "alternative to PHP"? It has nothing to do with PHP at all, except running a bash script with exec() and while(!noScreenshot){...} loop afterwards. If you want a purely PHP solution - there is no such. The problem here is that such solution will actually requere to write a whole web browser with a rendering engine on PHP - I don't think you want to go so far. – Cruel_Crow Apr 06 '14 at 13:23
  • 1
    You could also check one of the virtual browser services, like https://spoon.net/browsers/ or http://www.browserstack.com/ (just the first entries in Google search, not that I endorse them!) – Guillermo Prandi Apr 08 '14 at 03:56