Tools to Capture and Convert the Web

Advanced Screenshot Features with Perl

Perl API

Use the advanced features of the GrabzIt's Perl API to integrate closely with your appplication such as checking the status of existing screenshots or customizing the cookies used by GrabzIt when capturing screenshots.

Screenshot Status

Your app may need to check the status of a screenshot, perhaps to see if it is ready or to check if it is still cached and therefore available to be downloaded.

$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$status = $grabzIt.GetStatus(screenShotId);

if ($status->getProcessing())
{
    # screenshot has not yet been processed
}

if ($status->getCached())
{
    # screenshot is still cached by GrabzIt
}

if ($status->getExpired())
{
    # screenshot is no longer on GrabzIt
    # Perhaps output status message?
    die $status->getMessage();
}

Cookies

You may need to set a cookie to show or hide some functionaliy on a website. GrabzIt's cookie methods allows you to do this as shown below.

$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

# gets an array of cookies for google.com
@cookies = @{$grabzIt->GetCookies("google.com")};

foreach $cookie (@cookies)
{
    print $cookie->getName();
}

# sets a cookie for the google.com domain
$grabzIt->SetCookie("MyCookie", "google.com", "Any Value You Like");

# deletes the previously set cookie
$grabzIt->DeleteCookie("MyCookie", "google.com");

For all the options when setting, reading and deleting GrabzIt cookies please read the client documentation.

Display a Capture without Downloading

While its recommended a capture is downloaded to a web server before being used. It is possible to display any type of capture in a user's browser without downloading it onto your web server first.

To do this, once the capture has finished you can send the bytes of the capture returned by the SaveTo method to the response along with the correct mime type.

$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$grabzIt->URLToImage("https://www.tesla.com");
$capture = $grabzIt->SaveTo();

print "Content-type: image/jpeg\n\n";
print $capture;

An example of outputting a capture into a webpage is shown above for the URLToImage method, but it will work with any of the conversion methods.