{"id":2687,"date":"2017-08-07T19:15:13","date_gmt":"2017-08-07T19:15:13","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=2687"},"modified":"2022-03-17T12:23:54","modified_gmt":"2022-03-17T12:23:54","slug":"capture-screenshot-website-url-php-google-api","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/","title":{"rendered":"Capture Screenshot of Website from URL using PHP"},"content":{"rendered":"<p>Web page screenshot capture functionality is used for various purposes in the web application. Mostly, the website screenshot is used to display a preview of a web page. When website URLs are required to list on the web page, displaying website screenshots as a preview will provide a great user interface.<\/p>\n<p>There are various third-party APIs are available to <b>take screenshots of the website<\/b>. If you wish to build your own script to <b>get a screenshot from URL<\/b>, you can do it easily using PHP and Google PageSpeed Insights API.<\/p>\n<p>Generally, Google PageSpeed Insights API is used to measure the performance of a web page. But you can also use Google PageSpeed Insights API to get a screenshot of the website from the URL. In this tutorial, we will explain how to capture a screenshot of the website from URL using PageSpeed Insights API and PHP.<\/p>\n<p>The example script is designed to <b>capture screenshots of the website<\/b> or any online web pages with PHP.<\/p>\n<h2>Create Google API Key<\/h2>\n<p>An API key is required to authenticate with Google PageSpeed Insights API. You need to attach the API key to the URL of the Google PageSpeed Insights API. <\/p>\n<p>Before getting started, follow the below steps to enable the PageSpeed Insights API library and create an API key.<\/p>\n<ul class=\"step_list\">\n<li>Go to the <a href=\"https:\/\/console.developers.google.com\/\" target=\"_blank\" rel=\"noopener\">Google Developers Console<\/a>.<\/li>\n<li>Select the project from the Project drop-down menu at the top. If you don&#8217;t have an existing project, create a new one.<\/li>\n<li>In the sidebar, select Library under the APIs &#038; Services section.\n<ul class=\"bullet_disk_list\">\n<li>Search for the <b>PageSpeed Insights API<\/b> service in the API list and select PageSpeed Insights API.<\/li>\n<li>Click the ENABLE button to make the PageSpeed Insights API Library available.<\/li>\n<\/ul>\n<\/li>\n<li>In the sidebar, select <b>Credentials<\/b> under the <b>APIs &#038; Services<\/b> section.\n<ul class=\"bullet_disk_list\">\n<li>In the Credentials page, select <b>Create credentials<\/b> &raquo; <b>API key<\/b>.<\/li>\n<li>The API key will be created and a dialog will appear with the newly created API key.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Copy the <b>API key<\/b> for later use in the script on Google PageSpeed Insights API request.<\/p>\n<h2>Get Screenshot of Website from URL<\/h2>\n<p>The following code snippet helps to take a screenshot of the website by the URL and display it as a snapshot preview image. <\/p>\n<p>We will use Google PageSpeed Insights API to take screenshots of the website using PHP. The Google API key should be appended in the query parameter to all request URLs. Some of the required parameters are given below.<\/p>\n<ul class=\"bullet_disk_list\">\n<li><code>url<\/code> &#8211; Specify the URL of the website.<\/li>\n<li><code>screenshot<\/code> &#8211; Set it to <code>true<\/code> to retrieve the screenshot data.<\/li>\n<li><code>key<\/code> &#8211; Your API key.<\/li>\n<\/ul>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Google&nbsp;API&nbsp;key <br \/><\/span><span style=\"color: #0000BB\">$googleApiKey&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Your_API_KEY'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Website&nbsp;url <br \/><\/span><span style=\"color: #0000BB\">$siteURL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"https:\/\/www.codexworld.com\/\"<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Call&nbsp;Google&nbsp;PageSpeed&nbsp;Insights&nbsp;API <br \/><\/span><span style=\"color: #0000BB\">$googlePagespeedData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"https:\/\/www.googleapis.com\/pagespeedonline\/v5\/runPagespeed?url=<\/span><span style=\"color: #0000BB\">$siteURL<\/span><span style=\"color: #DD0000\">&amp;screenshot=true&amp;key=<\/span><span style=\"color: #0000BB\">$googleApiKey<\/span><span style=\"color: #DD0000\">\"<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Decode&nbsp;json&nbsp;data <br \/><\/span><span style=\"color: #0000BB\">$googlePagespeedData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$googlePagespeedData<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Retrieve&nbsp;screenshot&nbsp;image&nbsp;data <br \/><\/span><span style=\"color: #0000BB\">$screenshot_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$googlePagespeedData<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'lighthouseResult'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'audits'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'final-screenshot'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'details'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'data'<\/span><span style=\"color: #007700\">]; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Display&nbsp;screenshot&nbsp;image <br \/><\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;img&nbsp;src=\"'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'\"&nbsp;\/&gt;'<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<p>You can also save website screenshot as an image on the server with PHP.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Use <b>PHP file_put_contents()<\/b> function to create image file and write base64 data in it.<\/li>\n<\/ul>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Save&nbsp;screenshot&nbsp;as&nbsp;an&nbsp;image <br \/><\/span><span style=\"color: #007700\">list(<\/span><span style=\"color: #0000BB\">$type<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">)&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">explode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">';'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">); <br \/>list(,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">explode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">','<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$screenshot_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">base64_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #0000BB\">$output_file&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'images\/output.png'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">file_put_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$output_file<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<h2>Capture Website Screenshot from URL<\/h2>\n<p>In this example script, we will show how you can build a form to get website screenshot by the URL provided by the user and display the web page screenshot to the user.<\/p>\n<p><b>HTML Form to Get URL Input:<\/b><br \/>\nThe HTML form has one input field which accepts the URL of the website. <\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">form<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"post\"<\/span> <span class=\"hljs-attr\">action<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"getScreenshot.php\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"form-group\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>Website URL:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">label<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"text\"<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"form-control\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"site_url\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"\"<\/span> <span class=\"hljs-attr\">required<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"form-group\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"submit\"<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"form-control btn-primary\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"submit\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"Capture Screenshot\"<\/span>\/&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">form<\/span>&gt;<\/span><\/pre>\n<p>On form submission, the input value is posted to the server-side script (<code>getScreenshot.php<\/code>) to handle the screenshot capture process with PHP.<\/p>\n<p><b>Fetch and Save Screenshot with PHP (getScreenshot.php):<\/b><br \/>\nThis server-side script handles the screenshot capture process with Google PageSpeed Insights API using PHP.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Validate input value to check whether the given URL is valid using PHP FILTER_VALIDATE_URL Filter.<\/li>\n<li>Call the Google PageSpeed Insights API and fetch data with PHP file_get_contents() function.<\/li>\n<li>Retrieve screenshot image data of the website using PHP.<\/li>\n<li>Get domain name from website URL and use the domain as the output screenshot file name.<\/li>\n<li>Save base64 data in a file and save the screenshot as an image using PHP file_put_contents() function.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Google&nbsp;API&nbsp;key <br \/><\/span><span style=\"color: #0000BB\">$googleApiKey&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'AIzaSyAVYsI0pKADCpX7T6UuhHD0ql6l8cs3ZKA'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;If&nbsp;URL&nbsp;input&nbsp;is&nbsp;submitted <br \/><\/span><span style=\"color: #007700\">if(isset(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'site_url'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$site_url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'site_url'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$val_err&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">filter_var<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$site_url<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">FILTER_VALIDATE_URL<\/span><span style=\"color: #007700\">)&nbsp;===&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$val_err&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Please&nbsp;enter&nbsp;a&nbsp;valid&nbsp;website&nbsp;URL.'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(empty(<\/span><span style=\"color: #0000BB\">$val_err<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Call&nbsp;Google&nbsp;PageSpeed&nbsp;Insights&nbsp;API <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$googlePagespeedData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"https:\/\/www.googleapis.com\/pagespeedonline\/v5\/runPagespeed?url=<\/span><span style=\"color: #0000BB\">$site_url<\/span><span style=\"color: #DD0000\">&amp;screenshot=true&amp;key=<\/span><span style=\"color: #0000BB\">$googleApiKey<\/span><span style=\"color: #DD0000\">\"<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Decode&nbsp;json&nbsp;data <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$googlePagespeedData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$googlePagespeedData<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Retrieve&nbsp;screenshot&nbsp;image&nbsp;data <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$googlePagespeedData<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'lighthouseResult'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'audits'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'final-screenshot'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'details'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'data'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;domain&nbsp;name&nbsp;from&nbsp;site&nbsp;URL <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$pieces&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">parse_url<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$site_url<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$domain&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;isset(<\/span><span style=\"color: #0000BB\">$pieces<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'host'<\/span><span style=\"color: #007700\">])&nbsp;?&nbsp;<\/span><span style=\"color: #0000BB\">$pieces<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'host'<\/span><span style=\"color: #007700\">]&nbsp;:&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">preg_match<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'\/(?P&lt;domain&gt;[a-z0-9][a-z0-9\\-]{1,63}\\.[a-z\\.]{2,6})$\/i'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$domain<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$regs<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$domain&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$regs<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'domain'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Save&nbsp;screenshot&nbsp;as&nbsp;an&nbsp;image <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list(<\/span><span style=\"color: #0000BB\">$type<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">)&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">explode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">';'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list(,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">explode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">','<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">base64_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$file_name&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$domain<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #0000BB\">$domain<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'.png'<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #DD0000\">'output.png'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$output_file&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'screenshots\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$file_name<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">file_put_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$output_file<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$screenshot_data<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Screenshot&nbsp;saved&nbsp;as&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$output_file<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}catch(<\/span><span style=\"color: #0000BB\">Exception&nbsp;$e<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$e<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getMessage<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$val_err<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>} <br \/> <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Web page screenshot capture functionality is used for various purposes in the web application. Mostly, the website screenshot is used to display a preview of a web page. When website URLs are required to list <\/p>\n","protected":false},"author":1,"featured_media":4893,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[13,14,355,261,270],"class_list":["post-2687","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-google-api","tag-php","tag-screenshot","tag-url","tag-website","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Capture Screenshot of Website from URL using PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"Capture screenshot of website - Example script to take website screenshot from URL using PHP. Code snippet to get screenshot of website URL with Google PageSpeed Insights API using PHP.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Capture Screenshot of Website from URL using PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Capture screenshot of website - Example script to take website screenshot from URL using PHP. Code snippet to get screenshot of website URL with Google PageSpeed Insights API using PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-07T19:15:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-17T12:23:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/08\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Capture Screenshot of Website from URL using PHP\",\"datePublished\":\"2017-08-07T19:15:13+00:00\",\"dateModified\":\"2022-03-17T12:23:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/\"},\"wordCount\":637,\"commentCount\":11,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/08\\\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png\",\"keywords\":[\"Google API\",\"PHP\",\"Screenshot\",\"URL\",\"Website\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/\",\"name\":\"Capture Screenshot of Website from URL using PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/08\\\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png\",\"datePublished\":\"2017-08-07T19:15:13+00:00\",\"dateModified\":\"2022-03-17T12:23:54+00:00\",\"description\":\"Capture screenshot of website - Example script to take website screenshot from URL using PHP. Code snippet to get screenshot of website URL with Google PageSpeed Insights API using PHP.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/08\\\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/08\\\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/capture-screenshot-website-url-php-google-api\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Capture Screenshot of Website from URL using PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Capture Screenshot of Website from URL using PHP - CodexWorld","description":"Capture screenshot of website - Example script to take website screenshot from URL using PHP. Code snippet to get screenshot of website URL with Google PageSpeed Insights API using PHP.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/","og_locale":"en_US","og_type":"article","og_title":"Capture Screenshot of Website from URL using PHP - CodexWorld","og_description":"Capture screenshot of website - Example script to take website screenshot from URL using PHP. Code snippet to get screenshot of website URL with Google PageSpeed Insights API using PHP.","og_url":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2017-08-07T19:15:13+00:00","article_modified_time":"2022-03-17T12:23:54+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/08\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Capture Screenshot of Website from URL using PHP","datePublished":"2017-08-07T19:15:13+00:00","dateModified":"2022-03-17T12:23:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/"},"wordCount":637,"commentCount":11,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/08\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png","keywords":["Google API","PHP","Screenshot","URL","Website"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/","url":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/","name":"Capture Screenshot of Website from URL using PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/08\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png","datePublished":"2017-08-07T19:15:13+00:00","dateModified":"2022-03-17T12:23:54+00:00","description":"Capture screenshot of website - Example script to take website screenshot from URL using PHP. Code snippet to get screenshot of website URL with Google PageSpeed Insights API using PHP.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/08\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/08\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png","width":1366,"height":768,"caption":"capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/capture-screenshot-website-url-php-google-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Capture Screenshot of Website from URL using PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/08\/capture-website-screenshot-from-url-using-google-page-speed-insights-api-php-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-Hl","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=2687"}],"version-history":[{"count":5,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2687\/revisions"}],"predecessor-version":[{"id":4892,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2687\/revisions\/4892"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/4893"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=2687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=2687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=2687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}