捕获和转换Web的工具

PHP的高级屏幕截图功能

PHP API

GrabzIt的PHP API 高度可定制,并能够 int紧要 into您的应用程序。 它揭示了GrabzIt的许多内部工作原理,因此您可以尽可能自定义如何使用GrabzIt。 这方面的两个示例是检查现有屏幕截图的状态并设置GrabzIt在获取屏幕截图或捕获内容时将使用的cookie。

屏幕截图状态

使用GetStatus方法可让您的应用检查屏幕截图的状态,也许可以查看它是否仍在处理中,或者是否已缓存并准备使用。

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

$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?
    die $status->Message;
}

数据块

大多数网站使用Cookie来控制功能。 为了使您能够控制网站功能的这一方面,GrabzIt允许您使用以下内容设置自己的自定义Cookie cookie方法.

$grabzIt = new \GrabzIt\GrabzItClient("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");

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

显示捕获而不下载

虽然我们建议您在显示捕获之前将其下载到Web服务器。 您也可以在用户的​​浏览器中显示任何类型的捕获,而无需将其下载到Web服务器上。 但是,要使此技术起作用,用户将不得不等待捕获完成。

完成后,您可以发送由 SaveTo 方法 响应以及 正确的哑剧类型.

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

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

header("Content-Type: image/jpeg");
echo $grabzIt->SaveTo();

如您在上面的示例中看到的,没有文件名传递给 SaveTo 使该方法返回捕获内容的方法。