Capture Screenshot of Website from URL using PHP4 min read

In this post, we gonna write a simple PHP script to grab the given website URL screenshot.

There are many solutions to capture screenshots of Web pages. Using the Google Page Speed API is often better because internally Google uses the Chrome browser to capture exactly the way pages are presented to users.

In this tutorial we gonna use Bootstrap for design. Let’s create an HTML form to collect URLs from the user.


HTML Code:

PHP script to generate a screenshot for a given URL

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

Click here for API and create a request form here.

PHP Code:

All codes(sample.php):


  • Used this function too for a little while. Something I do not really like about it … It takes really a lot of time to capture the screenshot. Of course it depends on the pageload of the website too.

    Since a few months I am using PhantomJs and honestly it works faster and the quality of the screenshot is a lot better. No idea if Google has an option to output higher quality photos too.

Leave a Comment