Forked from jaseclamp/get webpage thumbnails from Google
Created
July 19, 2019 09:29
-
-
Save tareq1988/f3840b67b2668b0b920f87fe0d4e53aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sites = "http://www.broadcastsolutions.com.au/ | |
http://www.kvm.com.au/ | |
http://www.ambertech.com.au/"; | |
$sites = preg_split('/\r\n|\r|\n/', $sites); | |
echo " | |
<style> | |
img {float: left; margin: 15px; } | |
</style> | |
"; | |
foreach($sites as $site) | |
{ | |
//cache it | |
if ( !$image = apc_fetch( "thumbnail:".$site ) ) | |
{ | |
$image = file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=$site&screenshot=true"); | |
$image = json_decode($image, true); | |
//echo "<pre>"; print_r($image); die; | |
$image = $image['screenshot']['data']; | |
apc_add("thumbnail:".$site, $image, 2400); | |
} | |
$image = str_replace(array('_','-'),array('/','+'),$image); | |
echo "<img src=\"data:image/jpeg;base64,".$image."\" border='1' />"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment