Парсер всех блого-урлов яндекс "рейтинг блогов рунета"

premolly
На сайте с 13.02.2010
Offline
17
792


<?php
ini_set("max_execution_time","0");
ini_set("display_errors","on");

$html = file_get_contents ("http://blogs.yandex.ru/top/");
//echo strip_tags ($html);
if($html)
{
write_string("top.txt", "");

while (GetNextUrl($html) != false)
{
write_string("top.txt", implode("\n", GetTopsUrls($html)), "a");
write_string("html.html", $html);
$html = file_get_contents (GetNextUrl($html));
sleep(1);
}
}
else
{
echo "<h2>No File get contents</h2>";
}

function GetTopsUrls($html)
{
if(preg_match_all('~<a href="(.*)" class="container" style="background-image~iU', $html, $m))
{
print_r($m[1]);
}
return $m[1];
}



function GetNextUrl($html)
{
if(preg_match_all('~<a class="b-pager__next" href="(.*)">следующая</a>~iU', $html, $n))
{
echo "<h3>Next</h3>";
print_r($n[1][0]);
echo "<hr>";
if($n[1][0])
{
return $n[1][0];
}
}
return false;
}

//echo strip_tags ($html);



function write_string($filename, $record, $type = "w")
{
$logFile = fopen($filename,$type);
fwrite($logFile,$record);
fclose($logFile);
}
?>

Результат работы 52627 блого-урлов :idea: :bl:

Взять можно тут http://rghost.ru/18200101

з.ы. исходник здесь http://rghost.ru/18200301

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий