0

I'm looking for a small and lightweight way to get the screenshot of a website with just the URL. I've heard you can do this with XML/PHP, or even use another service to return the image. However, is there a fast simple way to do this? Preferably in Js? Also, to clarify, my project is going to be dynamically generating these thumbnails.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Carpetfizz
  • 8,707
  • 22
  • 85
  • 146
  • 1
    possible dublicate of http://stackoverflow.com/questions/757675/website-screenshots-using-php ? – Breezer Aug 06 '13 at 09:27
  • 1
    Perhaps You can have a look at a PhantomJs. It has the ability to take screenshots among other things – Dogoku Aug 06 '13 at 09:28
  • You can't just say "I want to do X. How about languages Y or Z?" You need to do some research into what's possible. – Lightness Races in Orbit Aug 06 '13 at 09:29
  • you could try [html2canvas](http://html2canvas.hertzen.com/) – bitWorking Aug 06 '13 at 09:29
  • 2
    This is a valid question. How would you dream up a solution for taking screenshots just like that. you wouldn't know where to start in php with this – SoWhat Aug 06 '13 at 09:32
  • 1
    I agree that you need html2canvas. Then you render the image like so: document.getElementById("newimg").src= document.getElementById("canvas").toDataURL("image/png"); But first you need the HTML of that URL, if cross-domain AJAX don't work - you 'll need PHP. – V.Vachev Aug 06 '13 at 09:36
  • 1
    You can use PhantomJS with PHP, take a look here https://github.com/microweber/screen And here is the api - http://screen.microweber.com/shot.php?url=http://stackoverflow.com/questions/18076297/take-screenshot-of-site-with-just-the-url – boksiora Aug 08 '13 at 07:00
  • Thanks much for the answers, I will definitely check out your links. PhantomJS seems like the optimal solution. If someone would post that as an answer, I will mark it as the correct answer for future readers. – Carpetfizz Aug 08 '13 at 08:28

1 Answers1

2

You can't do this with html/php alone. You need a browser to interpret the content on the page and get a screenshot. Some sort of software. OR use a 3party service http://www.browserstack.com/screenshots/api looks good, I haven't tried them though

SoWhat
  • 5,564
  • 2
  • 28
  • 59