捕获和转换Web的工具

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

Java API

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

为此,您需要使用 BrowserType 枚举值 MOBILEBROWSER 当创建一个 图片, PDF or , 如下所示。 然后,这将请求目标网站的移动版本。

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

ImageOptions options = new ImageOptions();
options.setFormat(ImageFormat.PNG);
options.setBrowserWidth(320);
options.setWidth(256);
options.setHeight(256);
options.setRequestAs(BrowserType.MOBILEBROWSER);

GrabzItClient grabzIt = new 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");