![]() ![]() Save base64 data in a file and save the screenshot as an image using PHP file_put_contents() function.Just like you can take screenshots on your phone, you can also do the same on your Windows computer.Get domain name from website URL and use the domain as the output screenshot file name.Retrieve screenshot image data of the website using PHP.Call the Google PageSpeed Insights API and fetch data with PHP file_get_contents() function.Validate input value to check whether the given URL is valid using PHP FILTER_VALIDATE_URL Filter.This server-side script handles the screenshot capture process with Google PageSpeed Insights API using PHP. ![]() On form submission, the input value is posted to the server-side script ( getScreenshot.php) to handle the screenshot capture process with PHP.įetch and Save Screenshot with PHP (getScreenshot.php): The HTML form has one input field which accepts the URL of the website. 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. $screenshot_data = base64_decode ( $screenshot_data ) įile_put_contents ( $output_file, $screenshot_data ) Capture Website Screenshot from URL List(, $screenshot_data ) = explode ( ',', $screenshot_data ) List( $type, $screenshot_data ) = explode ( ' ', $screenshot_data ) Use PHP file_put_contents() function to create image file and write base64 data in it.You can also save website screenshot as an image on the server with PHP. $googlePagespeedData = json_decode ( $googlePagespeedData, true ) ![]() $googlePagespeedData = file_get_contents ( " $siteURL &screenshot=true&key= $googleApiKey " )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |