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:
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")
# To take a image screenshot grabzIt.URLToImage("https://www.tesla.com") # Or to take a PDF screenshot grabzIt.URLToPDF("https://www.tesla.com") # Or to convert online videos into animated GIF's grabzIt.URLToAnimation("http://www.example.com/video.avi") # Or to capture table(s) grabzIt.URLToTable("https://www.tesla.com")
# To convert HTML into a image grabzIt.HTMLToImage("<html><body><h1>Hello World!</h1></body></html>") # Or convert HTML into a PDF document grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>") # Or convert HTML into a CSV, XLSX or JSON document grabzIt.HTMLToTable("<html><body><table><tr><th>Name</th><th>Age</th></tr> <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr> </table></body></html>")
# To convert HTML file into a image grabzIt.FileToImage("example.html") # Or convert HTML file into a PDF document grabzIt.FileToPDF("example.html") # Or convert HTML file into a CSV, XLSX or JSON document grabzIt.FileToTable("tables.html")
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.
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" grabzIt.SaveTo(filepath)
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.