GrabzIt Python API has many advanced features including enabling apps to check the status of existing screenshots and allowing the cookies that GrabzIt will use to be set by your application. Other useful features include mobile screenshots and custom watermarks.
For an application to check the status of a screenshot use the GetStatus method. This returns a status object that indicates if a capture is still processing, has an error message, is cached or has expired.
from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") status = grabzIt.GetStatus(screenShotId) if status.processing: # screenshot has not yet been processed if status.cached: # screenshot is still cached by GrabzIt if status.expired: # screenshot is no longer on GrabzIt # Perhaps output status message? raise Exception(status.Message)
A lot of websites control webpage functionality through cookies. GrabzIt allows you to set your own developer definied cookies in the following way.
from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") # gets an array of cookies for google.com cookies = grabzIt.GetCookies("google.com") # sets a cookie for the google.com domain grabzIt.SetCookie("MyCookie", "google.com", "Any Value You Like") # deletes the previously set cookie grabzIt.DeleteCookie("MyCookie", "google.com")
While this is a good overview of the cookie functionality the cookie methods do have more parameters as explained in the client documentation.
While its recommended a capture is downloaded to a web server before being used. 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 SaveTo method to the response along with the correct mime type.
from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") grabzIt.URLToImage("https://www.tesla.com") capture = grabzIt.SaveTo()
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.