GrabzIt's screenshot API is very flexible and can be called from a cronjob, a web page or app. The easiest way to add website screenshots or converting HTML to images, PDF and DOCX. To your Python app is by following these steps:
To use the API, you will first need to create an instance of the GrabzItClient class. Then pass your key and secret from your GrabzIt account to the constructor.
from GrabzIt import GrabzItClient
# Create the GrabzItClient class
# Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
Next you will need to use one of the image, PDF, animation or table methods. To request that the GrabzIt service capture the URL passed to it. Or convert HTML into an image, JPG or DOCX file.
# 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
# Or convert HTML into a PDF document
# 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, one of the two following save methods must be used to retrieve the capture. The recommended Save method requires the URL of a handler such as handler.py. This enables the capture to be retrieved asynchronously. This stops your app having to wait while a screenshot is created, and because it eliminates the need to repeatedly poll GrabzIt could potentially be faster.
The other save method is the synchonous SaveTo method, while this is simpler to use. It will force your app to wait while the screenshot is created.
So it should only be used in situations were the Save method cannot be used, such as in a desktop application or on localhost.
filepath = "images/result.jpg"
There are many more options when screenshots from web pages or converting HTML. Including; configuring the browser height and width, screenshot height and width. The delay before a capture is taken and the format of the capture. Find all these options and much more in the GrabzIt Client documentation.