GrabzIt's API is very customizable. Two useful features is the ability of the GrabzIt Node.js API to check the status of existing screenshots and to customize the cookies sent by GrabzIt when creating screenshots and capturing content. Other useful features include mobile screenshots and custom watermarks.
To check the status of a screenshot or capture use the get_status method this will return a status object that indicates if the capture is still being processed, is cached or has expired.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); client.get_status(screenShotId, function(error, status){ if (status.processing){ //screenshot has not yet been processed } if (status.cached){ //screenshot is still cached by GrabzIt } if (status.expired){ //screenshot is no longer on GrabzIt //Perhaps output status message? } });
A lot of website functionality is controlled through cookies. GrabzIt allows you to set your own custom cookies by using the cookie methods as shown below.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); //gets an array of cookies for google.com client.get_cookies("google.com", function(error, cookies){ }); //sets a cookie for the google.com domain client.set_cookie("MyCookie", "google.com", {"value":"Any Value You Like"}); //deletes the previously set cookie client.delete_cookie("MyCookie", "google.com");
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 oncomplete function of the save_to method to the response along with the correct mime type. An example of this for the url_to_image
method is shown below but it will work with any of the conversion methods.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); client.url_to_image("https://www.tesla.com"); client.save_to(null, function(error, data){ response.writeHead(200, {"Content-Type":"image/jpeg"}); response.write(data); response.end(); });