GrabzIt
Tools to Capture and Convert the Web

Take Website Screenshots with PerlPerl 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 and more to your Perl application is to follow these steps:

  1. Get your free Application Key and Secret.
  2. Download the free Perl Demo and Package and try it out.
  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 = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");

Then decide if you want to convert a web page into a image screenshot or PDF using the SetImageOptions or SetPDFOptions methods respectively. However if you want to convert a video into an animated GIF you will need to use the SetAnimationOptions method and to convert a HTML table into a CSV document you will need to use the SetTableOptions method. Then just pass the URL of the web page you want to convert to the method as shown below.

# To take a image screenshot
$grabzIt->SetImageOptions("http://www.google.com"); 	
# Or to take a PDF screenshot
$grabzIt->SetPDFOptions("http://www.google.com");
# Or to convert online videos into animated GIF's
$grabzIt->SetAnimationOptions("http://www.google.com");
# Or to capture table(s)
$grabzIt->SetTableOptions("http://www.google.com");

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"); 	

If the recommended Save method above can't be used then the synchonous SaveTo method can be used. However this will force your application to wait while the screenshot is created, it is then automatically saved to the specified file path.

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

More Options

There are many more screenshot 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.

Try all our premium features for free with a 3 day free trial. Then from $5.99 a month, unless cancelled.
  • More Captures
  • More Features
  • More API's
  • Bigger Scrapes
  • Bigger Screenshots
  • Bigger Everything
Start Free Trial