 |
| | | | |
 |
 |
Скрипт для определения тИЦ |  |
Скрипт парсит страницу, которая подготовлена для яндекс-бара с помощью domxml модуля.
<?
function getCY_url($url) { global $stack,$db; if (eregi('^http://www.',$url)) { $url_www = $url; $url = str_replace('http://www.','http://',$url); } else { $url_www = str_replace('http://','http://www.',$url); }
$file_www = "http://bar-navig.yandex.ru/u?ver=2&lang=1049&url=".urldecode($url_www)."&target=_No__Name:5&show=1&thc=0"; $file = "http://bar-navig.yandex.ru/u?ver=2&lang=1049&url=".urldecode($url)."&target=_No__Name:5&show=1&thc=0"; $handle = fopen($file_www, "rb"); $contents = ''; while (!feof($handle)) { $contents.= fread($handle, 8192); } fclose($handle); $dom = domxml_open_mem($contents); $root = $dom->document_element(); $root_child = $root->child_nodes(); for ($i = 0; $i < sizeof($root_child); $i++) { if ($root_child[$i]->node_name()=='tcy') { $cy_www = $root_child[$i]->get_attribute('value'); } } sleep(1); $handle = fopen($file_www, "rb"); $contents = ''; while (!feof($handle)) { $contents.= fread($handle, 8192); } fclose($handle); $dom = domxml_open_mem($contents); $root = $dom->document_element(); $root_child = $root->child_nodes(); for ($i = 0; $i < sizeof($root_child); $i++) { if ($root_child[$i]->node_name()=='tcy') { $cy = $root_child[$i]->get_attribute('value'); } } if ($cy>$cy_www) { return intval($cy); } else { return intval($cy_www); } } echo $_GET['url'].' '.getCY_url($_GET['url']); ?>
написано Деренченко Алексеем

|
 |