PhantomJS Screenshot a webpage

An interesting first demo to do with PhantomJS is to take a screenshot of a webpage.

It’s something I’ve often wanted to do over the years, and a few times I’ve cobbled various solutions together to do it. Sometimes using something like Applescript or automator, other times a mishmash of programming languages on a Linux server.

Getting going with PhantomJS I just loved how easy it was to get up and going, in just a few minutes I had PhantomJS installed, setup and my first scripted coded to take a screenshot of a webpage.

Let’s create our first PhantomJS script:

justdownforme-1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now, while that should work, the result might not look very good. Thanks to modern responsive websites, it may not default to a very nice size and shape.

So, next we’ll want to declare a size so we can retrieve something nice looking back.

Add the following:

 

Questions