Webをキャプチャして変換するツール

Javaによる高度なスクリーンショット機能

Java API

基本的なスクリーンショット機能に加えて GrabzItのJava API 既存のスクリーンショットのステータスを確認できるようにし、GrabzItがキャプチャを作成するときに使用するCookieをカスタマイズできるようにします。

スクリーンショットのステータス

アプリは、スクリーンショットのステータスを確認する必要がある場合があります。おそらく、スクリーンショットが取得されたかどうか、またはまだキャッシュされているかどうかを確認するためです。

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

Status status = grabzIt.GetStatus(screenShotId);

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

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

if (status.isExpired())
{
    // screenshot is no longer on GrabzIt
    // Perhaps output status message?
}

クッキー(Cookie)について

多くの場合、WebサイトはCookieを使用して、ユーザーが サインインしました。 以下のCookieメソッドを使用して、独自のカスタム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
Cookie[] 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の削除方法は、GrabzItに保存されている同じ名前とドメインのすべての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)
{ 
    String mimeType = "image/jpeg";
    capture.getBytes();
}

上記の例では、キャプチャのバイトとMIMEタイプを取得しますが、応答に返される方法は、使用しているフレームワークによって異なります。