捕获和转换Web的工具

使用Python拍摄移动网站的屏幕截图

Python API

GrabzIt Python API 提供了对网站的移动版本进行屏幕截图的功能,但是,并非所有网站都具有特殊的移动版本,因此可能无法在所有情况下都起作用。 图像和PDF屏幕截图以及提取表格时都可以请求移动屏幕截图。

为此,您需要使用1传递给 setRequestAs 创建对象时,options对象的属性 图片, PDF or , 如下所示。 然后,这将请求目标网站的移动版本。

为了获得更真实的手机屏幕截图,最好将标准的移动浏览器宽度传递给 browserWidth 的属性 GrabzItImageOptions 类。 或者,如果要创建PDF,请选择较小的页面尺寸。

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")