Das Laden einiger Webseiten kann eine Weile dauern oder bestimmte Inhalte enthalten intEs ist darauf eingestellt, dass es geladen werden kann, nachdem die Hauptseite geladen wurde. Dies gilt insbesondere für AJAX-lastige Webseiten, bei denen Inhalte über JavaScript geladen werden.
GrabzIt erkennt, wenn eine Webseite geladen wird. Für einige der oben aufgeführten spezifischen Umstände sind jedoch einige zusätzliche Anweisungen in Form einer Verzögerung erforderlich, die vor der Erfassung verwendet werden sollte, oder durch Warten auf das Erscheinen eines bestimmten HTML-Elements, bevor die Erfassung erfolgen soll voraus. Diese Techniken können verwendet werden, wenn Sie Screenshots von Webseiten erstellen oder HTML konvertieren into PDFs, Bilder oder Word-Dokumente, und Sie haben ein Premium-Paket. Allerdings sind beide Techniken auf eine maximale Wartezeit von dreißig Sekunden beschränkt.
Es empfiehlt sich, keine zu große Verzögerung zu verwenden, da in dem ungewöhnlichen Fall, dass Aufnahmen in die Warteschlange gestellt werden, eine große Verzögerung die Aufnahmepriorität verringert, obwohl dies durchaus möglich ist clevere Workarounds dazu.
Diese Funktionen sind auch in unserem verfügbar Online-Screenshot und Bahnschaber Werkzeuge.
Geben Sie einfach die Verzögerung in Millisekunden an und geben Sie an, wie lange die Aufnahme warten soll. Denken Sie daran, dass eine Sekunde 1000 Millisekunden hat. Alle folgenden Beispiele warten drei Sekunden, bevor die Webseite erfasst wird.
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.5.2/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")
https://api.grabz.it/services/convert?key=Sign in to view your Application Key&format=jpg&delay=3000&url=https%3A%2F%2Fspacex.com%2F
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")
Diese Technik ist besonders nützlich auf Webseiten, die AJAX-Methoden zum Laden von Inhalten verwenden. Verwenden Sie zunächst die Entwicklertools Ihres Browsers, um das Element zu identifizieren, auf dessen Anzeige Sie warten müssen. Notieren Sie sich dessen ID und Klasse oder erstellen Sie einen komplizierteren CSS-Selektor. Dann geben Sie dies an CSS-Selektor und sobald das Element sichtbar wird, wird die Webseite erfasst. Beachten Sie, dass bei mehreren übereinstimmenden HTML-Elementen dieses angezeigt wird, sobald eines sichtbar ist.
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.5.2/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")
https://api.grabz.it/services/convert?key=Sign in to view your Application Key&format=jpg&waitfor=%23Content&url=https%3A%2F%2Fspacex.com%2F
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")
Diese Technik kann in Verbindung mit der zuerst genannten Verzögerungsmethode verwendet werden. So können Sie warten, bis ein HTML-Element angezeigt wird, und dann einen weiteren Zeitraum abwarten, bevor Sie die Aufnahme erstellen.