Google Cache Dumper - дампер кеша Google
';
echo var_dump($var);
echo '';
}
function say($str)
{
static $n = 0;
echo "Msg #$n: $str
";
flush();
$n++;
}
if(isset($_GET['submit']))
{
$domain = $_GET['domain'];
$sleep = $_GET['sleep']*1000;
$p = $_GET['p'];
// Start parsing
$pages = array();
$parse = true;
for($i = 0; $parse && ($i < $p || $p == 0); $i++)
{
$page = file_get_contents('http://www.google.com/search?num=50&hl=ru&q=site:'.$domain.'&start='.$i*50 .'&sa=N');//('search.html');
$parse = preg_match_all('#
([^<]+) - [0-9]+k - #', $page, $matches);
foreach($matches[1] as $link)
{
$pages[] = $link;
say('Page found: '.$link);
}
usleep($sleep);
}
say('
Parsing finished!');
$dir = 'out/'.$domain;
@mkdir($dir, 0777);
chmod($dir, 0777);
say('
Starting downloading cache...');
foreach($pages as $page)
{
$part = parse_url('http://'.$page);
$container = $dir.'/'.$part['host'];
$file = $container.(($part['path']{strlen($part['path'])-1} == '/')?($part['path'].'index.html'):$part['path']);
@mkdir($container);
chmod($container, 0777);
$cache = file_get_contents('http://www.google.com/search?q=cache:'.$page);
file_put_contents($file, $cache);
chmod($file, 0777);
say("Page $page saved to $file");
flush();
usleep($sleep);
}
}
?>