Tools to Capture and Convert the Web

Take a screenshot of a mobile website with Python

Python API

The GrabzIt Python API provides the ability to take screenshots of mobile versions of websites, however not all websites have special mobile versions and so it may not work in all circumstances. Mobile screenshot can be requested for both image and PDF screenshots as well as when extracting tables.

To do this you need to use pass 1 to the setRequestAs attribute of the options object when creating a image, PDF or table, as shown below. This will then request the mobile version of the target website.

To get a more authenticate mobile screenshot it is also a good idea to pass a standard mobile browser width to the browserWidth attribute of the GrabzItImageOptions class. Or if you are creating a PDF choose a smaller page size.

from GrabzIt import GrabzItClient
from GrabzIt import GrabzItImageOptions

options = GrabzItImageOptions.GrabzItImageOptions()
options.format = "png"
options.browserWidth = 320
options.width = 256
options.height = 256
options.requestAs = 1

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
grabzIt.URLToImage("https://www.tesla.com", options)
grabzIt.Save("http://www.mysite.com/handler.py")