Saturday, August 23, 2014

php capture website screenshot script

8/23/2014

In this post we learn how to take websites screenshots very easily in PHP using Grabz.it 's API. First of all you need to create grabz.it account  to get API keys (APPLICATION KEY and APPLICATION SECRET) . Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account. The best way to put website screenshots into your PHP application is by using our simple PHP API.
<?php

/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/
include("GrabzItClient.class.php");

$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");// Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!

// To take a image screenshot
$grabzIt->SetImageOptions("http://www.google.com");     
// Or to take a PDF screenshot
$grabzIt->SetPDFOptions("http://www.google.com");
// Or to capture table(s)
$grabzIt->SetTableOptions("http://www.google.com");

?>

Above code is used to create class object with your account API key and secret after creating object we are calling 3 different methods SetImageOptions used to capture image of given page output, SetPDFOptions used to create PDF of given url and SetTableOptions is used to extract tables from the web page.

More Options

There are many more options including; configuring the browser height, browser width, screenshot height, screenshot width, the delay before a screenshot is taken and the image format of the screenshot. For all these options please see the Client documentation.


helpful? Share this

The Editorial Team of 4everTutorials consists of a group of PHP Professionals.

0 comments:

 

© 2014 4everTutorials. All rights resevered.

Back To Top