• Home |
  • Getting Started |
  • Upgrade |
  • Support |
  • ASP.NET
  • Java
  • JavaScript
  • Perl
  • PHP
  • Python
  • Introduction
  • Image options
  • PDF options
  • Table options
  • Advanced
  • GrabzItClient
  • GrabzItHandler
  • Download
  • Ruby
  • Python Introduction to GrabzIt

    The easiest way to add screenshots to your Python application is by using our simple Python library.

    The diagnostics panel can help you debug your code!

    GrabzIt is very flexible and could be called from a cronjob, a web page or application.

    First of all create the GrabzItClient class. Pass your application key and application secret from your GrabzIt account to the constructor.

    import GrabzItClient
    
    # Create the GrabzItClient class
    # Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
    grabzIt = GrabzItClient.GrabzItClient("APPLICATION KEY", "APPLICATION SECRET")
    

    Then use one of the SetImageOptions, SetPDFOptions or SetTableOptions methods to request that the GrabzIt service take a screenshot of the URL passed to it.

    # To take a image screenshot
    grabzIt.SetImageOptions("http://www.google.com"); 	
    # Or to take a PDF screenshot
    grabzIt.SetPDFOptions("http://www.google.com");
    # Or to capture table(s)
    grabzIt.SetTableOptions("http://www.google.com");
    

    Then use one of the following save methods. Notice that we also include the URL to the handler.py this handler will handle the callback from the service and save the resulting screenshot.

    grabzIt.Save("http://www.example.com/handler.py") 	
    

    Alternatively the synchonous SaveTo method, this 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 screenshot is created it is saved to the file path provided.

    filepath = "images/test.jpg"
    grabzIt.SaveTo(filepath) 	
    

    More Options

    There are many more options 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 please see the GrabzItClient documentation.