捕獲和轉換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.4.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")