Tools to Capture and Convert the Web

Advanced Screenshot Features with RubyRuby API

As well as the standard screenshot functionality GrabzIt's Ruby API allows developers to integrate closely with GrabzIt by enabling your application to hook into the inner workings of GrabzIt's service, by for example checking the status of existing screenshots and setting the cookies that GrabzIt will use when capturing web content.

Screenshot Status

An application may need to check the status of a capture and this is were the get_status method is useful, it returns an object that indicates if a capture is still processing, cached or has expired along with returning any error messages associated with the capture.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

status = grabzItClient.get_status(screenShotId)

if status.processing
    #screenshot has not yet been processed
end

if status.cached
    #screenshot is still cached by GrabzIt
end

if status.expired
    #screenshot is no longer on GrabzIt
    #Perhaps output status message?
    raise status.message
end

Cookies

Almost all websites control functionality with cookies. To enable you to alter the website functions of the target website GrabzIt exposes the following cookie methods, for more information on the parameters that are available for these methods please read the client documentation.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

#gets an array of cookies for google.com
cookies = grabzItClient.get_cookies("google.com")

#sets a cookie for the google.com domain
grabzItClient.set_cookie("MyCookie", "google.com", "Any Value You Like")

#deletes the previously set cookie
grabzItClient.delete_cookie("MyCookie", "google.com")

Display a Capture without Downloading

It is recommended a capture is downloaded to a web server before being used. However 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 save_to method to the response along with the correct mime type.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

grabzItClient.url_to_image("http://www.google.com")	
capture = grabzItClient.save_to();

In the example above we get the bytes of the capture but how it is returned to the response will depend on the framework you are using.