Posted by Arjun Arjun on Wednesday 29th November 2017, 1 minute read

How to capture screenshot of website with a URL using PHP

How to PHP Code Snippets URL capture screenshot

In this post, we gonna write a simple PHP script to grab given website URL screenshot. So let's create an HTML form to collect URL form the user.


Website URL:

We have just created a simple form with one field called URL and submit button. Submit button is to send the request to the server. Form action is pointed to screenCaptureFromURL.php, so lets create screenCaptureFromURL.php file.

PHP script to generate screenshot for a given URL

We gonna use google apis to grap the website screenshot and code is commented pretty well, just through the comments for better understanding.

        echo "Please enter a valid URL.";

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.