捕获和转换Web的工具

ASP.NET的高级屏幕截图功能

ASP.NET API

以及基本的屏幕截图功能 GrabzIt ASP.NET API 允许开发人员检查现有屏幕快照的状态,并设置GrabzIt用于为开发人员获取屏幕截图的cookie。

屏幕截图状态

有时,应用程序可能需要检查屏幕截图的状态,以查看其是否已被使用或是否仍在缓存中。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

ScreenShotStatus status = grabzIt.GetStatus(screenShotId);

if (status.Processing)
{
    // screenshot has not yet been processed
}

if (status.Cached)
{
    // screenshot is still cached by GrabzIt
}

if (status.Expired)
{
    // screenshot is no longer on GrabzIt
    // Perhaps output status message?
    label.Text = status.Message;
}

Cookies

某些网站通过Cookie控制功能。 GrabzIt允许您通过以下方式设置自己的开发人员定义的cookie。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

// gets an array of cookies for google.com
GrabzItCookie[] cookies = grabzIt.Cookies("google.com");

# sets a cookie for the google.com domain
grabzIt.SetCookie("MyCookie", "google.com", "Any Value You Like");

# deletes the previously set cookie
grabzIt.DeleteCookie("MyCookie", "google.com");

请注意,删除cookie方法将删除所有具有相同名称和域的cookie。

显示捕获而不下载

虽然建议将捕获内容使用之前下载到Web服务器。 可以在用户浏览器中显示任何类型的捕获,而无需先将其下载到Web服务器上。

捕获完成后,您可以发送由 SaveTo 方法 响应以及 正确的哑剧类型.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

grabzIt.URLToImage("https://www.tesla.com");
GrabzItFile capture = grabzIt.SaveTo();

if (capture != null)
{
    Response.ContentType = "image/jpeg";
    Response.BinaryWrite(capture.Bytes);
}

上面显示了针对响应输出捕获的示例 URLToImage 方法,但可以与任何转换方法一起使用。