How to capture website screenshot with PHP
I have received many requests from my readers to write on screenshot capture with PHP so I have found a service using that service we can take websites screenshots very easily in PHP. Used API’s from GrabzIt for testing in our demo you can get a website’s screenshot by sending a web url.
First of all you need to create your account on Grabz.It and they will give you API keys using these keys you can easily integrate it in your application.
Let’s come to the code:
<?php include("GrabzItClient.class.php"); $grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");// Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account! // image screenshot $grabzIt->SetImageOptions("https://www.phpgang.com"); // PDF screenshot $grabzIt->SetPDFOptions("http://www.wptutorialsacademy.com"); // capture table(s) $grabzIt->SetTableOptions("http://demo.phpgang.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.
To save screenshot in your website use below function:
<?php $grabzIt->Save("http://www.site.com/handler.php"); ?>
Use this function after your screenshot call and it will save your results directory make sure that you have given writing rights to that directory.
That’s all for screen capture application I hope it helps you guyz please share it with your friends. Follow us on twitter for more updates.
Tutorial Categories:
Awesome, But how to remove watermark from captured image ?
Awesome, This is a really nice article, easy to use to capture website screenshot!
this article is good but there need api key and SECRET code can u help without api key and SECRET code. this article good for home practice not for any real project
gijo can u help me how to do this and its working thats really good
How to remove water mark and make better quality of image?
thanks to share php capture … such a great !
Thnx