Site icon Learn Web Development & Programming, Artificial Intelligence, WordPress, Shopify Articles

How to Capture website Screenshot through website URL using Google PageSpeed Insights API and PHP

screenshot-capture

In this article you will learn “How to Capture website Screenshot through website URL using Google PageSpeed Insights API and PHP

Usually, Google PageSpeed Insight API is used to check the performance and speed of any website or webpage. But you never used Google PageSpeed Insights API to get website screenshot using URL. Website page screenshot capture functionality is used for many purposes in the web application.

Now you can also use Google PageSpeed Insights API to capture a screenshot of webpage from URL. There are various third party APIs available to capture a screenshot of the website. But if you want to build your own script to capture a screenshot from URL. With the help of Google PageSpeed Insights API and PHP You can do it easilly.

Follow the below example script to takes a screenshot of the website by URL:

To create web page snapshot, Google PageSpeed Insights API need to be called using following params.

url: Specify the URL of webpage or website

Screenshot: Specify screenshot=true to retrieve the screenshot data.

Get Website Screenshot from URL

In this example, we will show you “how you can build a form to capture website screenshot by the URL provided by the user and display the page screenshot to user”.

HTML Code:

Following HTML form create a input field which is used to enter website URL.

capturescreenshot.php

Following PHP code is used to validate the submitted input URL value before calling the Google PageSpeed Insights API. The Screenshot data retrieved from the Google PageSpeed Insights API and image of the website screenshot is shown.

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request
[sociallocker]

[/sociallocker]

Exit mobile version