Tools to Capture and Convert the Web

Take Website Screenshots with Ruby

Ruby API
The diagnostics panel can help you debug your code!

GrabzIt's screenshot API is very flexible and can be called from any type of Ruby application. The best way to put website screenshots or HTML to image functionality and more into your Ruby app is by following these steps:

  1. Get your free Application Key and Secret.
  2. Download the free Ruby Library and try out the Demo Application.
  3. Find out the basics about how GrabzIt's API works by reading the below overview.

Ruby API Overview

First create an instance of the Client class, passing your application key and application secret from your GrabzIt account to the constructor to start using GrabzIt's API .

require 'grabzit'

grabzItClient ="Sign in to view your Application Key", "Sign in to view your Application Secret")

Then use one of the image, PDF, animation or table methods to capture a URL or convert HTML.

# To take a image screenshot
# Or to take a PDF screenshot
# Or to convert online videos into animated GIF's
# Or to capture table(s)
# To convert HTML into a image
grabzItClient.html_to_image("<html><body><h1>Hello World!</h1></body></html>")	
# Or convert HTML into a PDF document
grabzItClient.html_to_pdf("<html><body><h1>Hello World!</h1></body></html>")
# Or convert HTML into a CSV, XLSX or JSON document
# To convert HTML file into a image
# Or convert HTML file into a PDF document
# Or convert HTML file into a CSV, XLSX or JSON document

Finally use one of the following save methods to complete the capture. The Save method requires the URL of a handler, which will process the callback from GrabzIt to save the resulting screenshot."") 	
Always use the save_to method on localhost

Another option is to use the synchonous save_to method, which will force your application to wait while the screenshot is created so it should only be used were the save method cannot be used.

Once the capture is created it is saved to the file path provided.

filepath = "images/result.jpg"

More Options

There are many special features that can be used when taking screenshots of webpages or converting HTML. 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 read the Client documentation.