使用高级功能 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(); }
您可能需要设置一个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
方法,但可以与任何转换方法一起使用。