Tools to Capture and Convert the Web

Take Website Screenshots with Perl

Perl API
The diagnostics panel can help you debug your code!

GrabzIt's screenshot API is very flexible and can be called in many ways such as from a cronjob, a web page or application. The simplest way to add screenshots or HTML to conversion functionality and more to your Perl application is to follow these steps:

  1. Get your free Application Key and Secret.
  2. Download the free Perl Library and try out the Demo Application.
  3. Find out the basics about how GrabzIt's API works by reading the below overview.

Perl API Overview

To use the API you will first need to create an instance of the GrabzItClient class and pass your application key and application secret from your GrabzIt account to the constructor.

#!/usr/bin/perl

use GrabzItClient;

# Create the GrabzItClient class
# Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

Then use one of the image, PDF, animation or table methods to capture a URL or convert HTML.

# To take a image screenshot
$grabzIt->URLToImage("https://www.tesla.com"); 	
# Or to take a PDF screenshot
$grabzIt->URLToPDF("https://www.tesla.com");
# Or to convert online videos into animated GIF's
$grabzIt->URLToAnimation("http://www.example.com/video.avi");
# Or to capture table(s)
$grabzIt->URLToTable("https://www.tesla.com");
# To convert HTML into a image
$grabzIt->HTMLToImage("<html><body><h1>Hello World!</h1></body></html>"); 	
# Or convert HTML into a PDF document
$grabzIt->HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>");
# Or convert HTML into a CSV, XLSX or JSON document
$grabzIt->HTMLToTable("<html><body><table><tr><th>Name</th><th>Age</th></tr>
    <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr>
    </table></body></html>");
# To convert HTML file into a image
$grabzIt->FileToImage("example.html"); 	
# Or convert HTML file into a PDF document
$grabzIt->FileToPDF("example.html");
# Or convert HTML file into a CSV, XLSX or JSON document
$grabzIt->FileToTable("tables.html");

Finally use one of the two following save methods. The first save method shown below requires the URL of handler.pl this handler will process the callback from GrabzIt and save the resulting screenshot.

$grabzIt->Save("http://www.example.com/handler.pl"); 	
Always use the SaveTo method on localhost

If the recommended Save method above can't be used then the synchonous SaveTo method should be used instead.

However this will force your application to wait while the capture is created, once finished it is automatically saved to the specified file path.

$filepath = "images/result.jpg";
$grabzIt->SaveTo($filepath);

More Options

When creating screenshots or converting HTML there are many more options including; configuring the browser height, browser width, screenshot height, screenshot width, the delay before a screenshot is taken and the image format of the screenshot. For all these options and more please see the Client documentation.