捕獲和轉換Web的工具

Perl的高級屏幕截圖功能

Perl API

使用高級功能 GrabzIt的Perl API 至 int與您的應用程序緊密協作,例如檢查現有屏幕截圖的狀態或自定義GrabzIt在捕獲屏幕截圖時使用的cookie。

屏幕截圖狀態

您的應用可能需要檢查屏幕截圖的狀態,也許是為了查看屏幕快照是否準備就緒,或者是否仍在緩存中,因此可以下載。

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

$status = $grabzIt.GetStatus(screenShotId);

if ($status->getProcessing())
{
    # screenshot has not yet been processed
}

if ($status->getCached())
{
    # screenshot is still cached by GrabzIt
}

if ($status->getExpired())
{
    # screenshot is no longer on GrabzIt
    # Perhaps output status message?
    die $status->getMessage();
}

Cookies

您可能需要設置一個cookie,以顯示或隱藏網站上的某些功能。 GrabzIt的cookie方法使您可以如下所示進行操作。

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

# gets an array of cookies for google.com
@cookies = @{$grabzIt->GetCookies("google.com")};

foreach $cookie (@cookies)
{
    print $cookie->getName();
}

# 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");

有關設置,讀取和刪除GrabzIt cookie的所有選項,請閱讀 客戶文件.

顯示捕獲而不下載

雖然建議將捕獲的內容使用前下載到Web服務器。 可以在用戶瀏覽器中顯示任何類型的捕獲,而無需先將其下載到Web服務器上。

為此,捕獲完成後,您可以發送由 SaveTo 方法 響應以及 正確的啞劇類型.

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

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

print "Content-type: image/jpeg\n\n";
print $capture;

輸出捕獲的示例 int上面顯示了oa網頁 URLToImage 方法,但可以與任何轉換方法一起使用。