Hello all.
Is there any way to clear Internet Explorers cache using the COM object?
I am running a screen scraping script to generate thumbnails of my templates, but sometimes the thumbs get duplicated.
TIA!
<?php
$root_dir = dirname(__FILE__);
$tpl_dir = $root_dir.'\\templates';
$img_dir = $root_dir.'\\scraps';
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->FullScreen = true;
$browser->ShowBrowserBar = false;
$browser->StatusBar = false;
$dir = dir($tpl_dir);
/** loop templates **/
while(($res = $dir->read()) !== FALSE){
set_time_limit(60);
if($res == '.' || $res == '..') continue;
try {
if(is_file($tpl_dir.'\\'.$res.'\\html\\index.html'))
$browser->Navigate($tpl_dir.'\\'.$res.'\\html\\index.html');
elseif(is_file($tpl_dir.'\\'.$res.'\\html\\index.htm'))
$browser->Navigate($tpl_dir.'\\'.$res.'\\html\\index.htm');
else
continue;
while ($browser->Busy) {
com_message_pump(2000);
}
$im = imagegrabwindow($handle, 0);
imagepng($im, $img_dir.'\\'.$res.".png");
imagedestroy($im);
} catch(Exception $e){
$handle = fopen("scrap_log.txt", "a");
fwrite($handle, "Could not scrap ".$res."\n");
fclose($handle);
}
}
$browser->Quit();
?>