基本的なスクリーンショット機能と同様に、 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; }
一部のWebサイトは、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");
delete cookieメソッドは、同じ名前とドメインを持つすべてのcookieを削除することに注意してください。
キャプチャを使用する前にWebサーバーにダウンロードすることをお勧めしますが。 最初にWebサーバーにダウンロードせずに、ユーザーのブラウザーに任意の種類のキャプチャを表示することができます。
キャプチャが完了すると、キャプチャによって返されるキャプチャのバイトを送信できます SaveTo 方法 応答とともに 正しいMIMEタイプ.
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
メソッドですが、どの変換メソッドでも機能します。