以及基本的屏幕截圖功能 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; }
某些網站通過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
方法,但可以與任何轉換方法一起使用。