Tools to Capture and Convert the Web

Callback Handler with Node.js

Node.js API


Having problems debugging your handler? Try the Callback Handler Test Tool.

The handler or web hook described here processes callbacks from the GrabzIt screenshot web service. The URL of this handler is passed to GrabzIt in the callBackUrl parameter of the save method. However this technique will only work if the handler is accessible via the Internet.

The following parameters are passed to the handler as GET parameters.

If you want to block all access to the handler, except from GrabzIt then use this security technique.


Remember this callback will not work if your application is located on localhost.

This example shows how a GrabzIt Node.js handler can be implemented using express. This captures six parameters passed to it from the GrabzIt service, including the unique id of the screenshot which is passed to the get_result method.

This method then returns the screenshot, which is saved in the screenshot directory.

var express = require('express');
var url = require('url');
var file = require('fs');
var grabzit = require('grabzit');

var app = express();

app.get('/handler', function (req, res) {
    var queryData = url.parse(req.url, true).query;

    var message = queryData.message;
    var customid = queryData.customid;
    var id =;
    var filename = queryData.filename;
    var format = queryData.format;
    var targeterror = queryData.targeterror;

    var client = new grabzit('Sign in to view your Application Key', 'Sign in to view your Application Secret")%>');

    client.get_result(id, function(err, result){
        if (err != null) {            

        file.writeFile(path.join('public', path.join('results', filename)), result, 'binary');