Capture Screenshots in Python

By Maximus1983 on Jun 27, 2012

Capture Web Screenshots easily with the GrabzIt Python API. You will need the free GrabzIt Python Code Library to get started.

For more information on the API visit.

Register to get your free Application Key and Application Secret.

    # The Python that takes the screenshot

    import GrabzItClient

    #Create the GrabzItClient class
    #Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
    grabzIt = GrabzItClient.GrabzItClient("APPLICATION KEY", "APPLICATION SECRET")
    #Take the picture the method will return the unique identifier assigned to this task
    id = grabzIt.TakePicture("", "")

    # The GrabzItHandler file that saves the screenshot

    import os
    import cgi
    import GrabzItClient

    form = cgi.FieldStorage()

    message = form.getvalue("message")
    customId = form.getvalue("customid")
    id = form.getvalue("id")
    filename = form.getvalue("filename")

    #Custom id can be used to store user ids or whatever is needed for the later processing of the
    #resulting screenshot

    grabzIt = GrabzItClient.GrabzItClient("APPLICATION KEY", "APPLICATION SECRET")
    result = grabzIt.GetPicture(id)

    if result != None:
    #Ensure that the application has the correct rights for this directory.
    fo = open("images" + os.sep + filename, "wb")

    print "Status: 200 OK"


Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.