捕获和转换Web的工具

GrabzIt API的检索方法

有两种方法可用于从GrabzIt的API检索屏幕截图,表格捕获和GIF动画,这两种方法各有优缺点。

异步方式

回调方法

也称为回调方法,这是检索捕获的推荐方法。 但是,它确实要求所构建的应用程序具有域名或公共可用的IP地址。 可以使用此方法的一个示例是Web应用程序。

从该图中可以看出,异步方法的工作原理是将调用发送到GrabzIt,然后等待将调用发送回应用程序,表明屏幕快照已准备就绪。 使用此方法的优点是它需要较少的调用,并允许其他进程(例如Web请求)继续进行int爆发。

下面显示了GrabzIt当前支持的每种服务器端语言的异步调用示例。

请记住,为了异步调用GrabzIt的API,您将需要实现此ASP.NET 处理器.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
grabzIt.URLToImage("http://www.spacex.com");
grabzIt.Save("http://www.mywebsite.com/Home/Handler");

请记住,为了异步调用GrabzIt的API,您将需要实现此Java 处理器.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
grabzIt.URLToImage("http://www.spacex.com");
grabzIt.Save("http://www.mywebsite.com/handler");

请记住,为了异步调用GrabzIt的API,您将需要实现此Node.js。 处理器,但是不要将此与Node.js函数回调混淆。 这里讨论的回调是通过Internet发送的HTTP回调!

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
client.url_to_image("http://www.spacex.com");
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});

请记住,为了异步调用GrabzIt的API,您将需要实现此Perl 处理器.

$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");
$grabzIt->URLToImage("http://www.spacex.com");
$grabzIt->Save("http://www.mywebsite.com/handler.pl");

请记住,为了异步调用GrabzIt的API,您将需要实现此PHP 处理器.

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$grabzIt->URLToImage("http://www.spacex.com");
$grabzIt->Save("http://www.mywebsite.com/handler.php");

请记住,为了异步调用GrabzIt的API,您将需要实现此Python 处理器.

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
grabzIt.URLToImage("http://www.spacex.com")
grabzIt.Save("http://www.mywebsite.com/handler.py")

请记住,为了异步调用GrabzIt的API,您需要实现此Ruby 处理器.

grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
grabzIt.url_to_image("http://www.spacex.com")
grabzIt.save("http://www.mywebsite.com/handler/index")

同步方式

轮询方式

仅在无法使用异步方法的情况下才应使用此方法。 同步方法的工作原理是,向GrabzIt发送调用以创建捕获,然后每隔几秒钟轮询一次GrabzIt,直到准备就绪为止,如图所示。

准备就绪后,它将照常下载捕获的内容。 该技术的缺点是,它迫使当前进程等待捕获完成,这就是为什么它不适用于Web应用程序的原因。 但是,优点是该应用程序不需要域名或IP地址,因此可以从桌面应用程序中使用。

下面显示了GrabzIt当前支持的每种服务器端语言的同步调用示例。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
grabzIt.URLToImage("http://www.spacex.com");
grabzIt.SaveTo("spacex.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
grabzIt.URLToImage("http://www.spacex.com");
grabzIt.SaveTo("spacex.jpg");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.3.7/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com").Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
client.url_to_image("http://www.spacex.com");
client.save_to("spacex.jpg", function (error, id){
    if (error != null){
        throw error;
    }
});
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");
$grabzIt->URLToImage("http://www.spacex.com");
$grabzIt->SaveTo("spacex.jpg");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$grabzIt->URLToImage("http://www.spacex.com");
$grabzIt->SaveTo("spacex.jpg");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
grabzIt.URLToImage("http://www.spacex.com")
grabzIt.SaveTo("spacex.jpg")
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
grabzIt.url_to_image("http://www.spacex.com")
grabzIt.save_to("spacex.jpg")