捕获和转换Web的工具

如何在执行捕获之前等待网页加载?

主要内容之后加载的网页上的项目

某些网页可能需要一段时间才能加载或包含特定内容 int可能会在加载主页后加载。 在通过JavaScript加载内容的AJAX繁重的网页上尤其如此。

GrabzIt可以检测到何时加载网页,但对于上面列出的某些特定情况,它需要一些其他说明,例如在捕获之前应使用的延迟形式,或者通过等待指定的HTML元素出现在捕获应该开始之前使用延迟先。 如果您要截取网页的屏幕截图或转换HTML,则可以使用这些技术 into PDF,图像或Word文档,您将获得一个高级软件包。 尽管您可以通过我们的免费试用这些功能 七天免费试用.

这些功能也可以在我们的 在线截图 刮板机 工具。

如何在执行捕获之前等待指定的时间?

只需指定延迟(以毫秒为单位),这就是捕获将等待的时间。 请记住,一秒有1000毫秒。 以下所有示例在捕获网页之前等待三秒钟。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
ImageOptions options = new ImageOptions();
options.Delay = 3000;
grabzIt.URLToImage("http://www.spacex.com", options);
grabzIt.SaveTo("images/result.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
ImageOptions options = new ImageOptions();
options.setDelay(3000);
grabzIt.URLToImage("http://www.spacex.com", options);
grabzIt.SaveTo("images/result.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", 
{"delay": 3000}).Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
var options = {"delay":"3000"};
client.url_to_image("http://www.spacex.com", options);
client.save_to("images/result.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");
$options = GrabzItImageOptions->new();
$options->delay(3000);
$grabzIt->URLToImage("http://www.spacex.com", $options);
$grabzIt->SaveTo("images/result.jpg");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = new \GrabzIt\GrabzItImageOptions();
$options->setDelay(3000);
$grabzIt->URLToImage("http://www.spacex.com", $options);
$grabzIt->SaveTo($filepath);
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzItImageOptions.GrabzItImageOptions()
options.delay = 3000
grabzIt.URLToImage("http://www.spacex.com", options)
grabzIt.SaveTo("images/result.jpg")
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzIt::ImageOptions.new()
options.delay = 3000
grabzItClient.url_to_image("http://www.spacex.com", options)
grabzItClient.save_to("images/result.jpg")

如何在执行捕获之前等待HTML元素出现?

该技术在使用AJAX方法加载内容的网页上特别有用。 首先使用您的浏览器开发人员工具来确定需要等待出现的元素,并记下其ID或类。 然后将此类或ID指定为 标准CSS选择器 并且一旦该元素变得可见,便会捕获网页。 请注意,如果有多个匹配的HTML元素,则它们将在可见时立即显示。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
ImageOptions options = new ImageOptions();
options.WaitForElement = "#Content";
grabzIt.URLToImage("http://www.spacex.com", options);
grabzIt.SaveTo("images/result.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
ImageOptions options = new ImageOptions();
options.setWaitForElement("#Content");
grabzIt.URLToImage("http://www.spacex.com", options);
grabzIt.SaveTo("images/result.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", 
{"waitfor": "#Content"}).Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
var options = {"waitForElement":"#Content"};
client.url_to_image("http://www.spacex.com", options);
client.save_to("images/result.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");
$options = GrabzItImageOptions->new();
$options->waitForElement("#Content");
$grabzIt->URLToImage("http://www.spacex.com", $options);
$grabzIt->SaveTo("images/result.jpg");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = new \GrabzIt\GrabzItImageOptions();
$options->setWaitForElement("#Content");
$grabzIt->URLToImage("http://www.spacex.com", $options);
$grabzIt->SaveTo($filepath);
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzItImageOptions.GrabzItImageOptions()
options.waitForElement = "#Content"
grabzIt.URLToImage("http://www.spacex.com", options)
grabzIt.SaveTo("images/result.jpg")
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzIt::ImageOptions.new()
options.waitForElement = "#Content"
grabzItClient.url_to_image("http://www.spacex.com", options)
grabzItClient.save_to("images/result.jpg")