Taking website screenshot, server-side, on a Linux rented server, free

casraf picture casraf · Jul 27, 2010 · Viewed 12.1k times · Source

Ok so, right now I can't really afford to pay for any service. I want to be able to take screenshots using my rented server, which is Linux based, and output them on the screen.

I know there are a lot of services that do this, but they usually have limits or watermarks, or you have to wait for your screenshot to be taken from the queue.

Is there any way to just take the screenshots myself and maybe later cache them or anything? I'm using PHP, but I'm not limited to it; I'm just on a Linux server so GD's appropriate functions wouldn't work. Help! :)

Answer

cromulus picture cromulus · Oct 19, 2011

PhantomJs is the solution

if(phantom.state.length === 0){
  phantom.state = '0_home';
  phantom.open('http://www.mini.de');
}
else if(phantom.state === '0_home'){
  phantom.viewportSize = {width: 800, height: 600};
  phantom.sleep(2000);
  phantom.render('home.png');
  phantom.exit(0);
}