Подсчет количества ссылок на сайт в поисковых системах Google и Yahoo
+ индексацию сайта в этих же поисковиках
<?php
function GetLinksCount($url,$engine) {
$arrayData = array();
$urlI = trim(eregi_replace('http://', '', $url));
$arr = @parse_url($url);
$url = $arr['host'];
//google parameters
$arrayData['google'][0] = "http://www.google.com/
search?hl=en&lr=&ie=UTF-8&q=link%3A$urlI";
$arrayData['google'][1] = "of about";
$arrayData['google'][2] = "of ";
$arrayData['google'][3] = "linking to";
$arrayData['google'][4] = 3; //to ['google'][2]
$arrayData['google'][5] = 9; //to ['google'][1]
//yahoo parameters
$arrayData['yahoo'][0] = "http://search.yahoo.com/
search?_adv_prop=web&x=op&va=linkdomain%3A$urlI+-site%3A
$urlI&va_vt=any&vp_vt=any&vo_vt=any&ve_vt=any&vd=all&ei=
UTF-8&vst=0&vf=all&vm=i&fl=0&n=40";
$arrayData['yahoo'][1] = "of about";
$arrayData['yahoo'][2] = "of ";
$arrayData['yahoo'][3] = "for linkdomain:";
$arrayData['yahoo'][4] = 3; //to ['yahoo'][2]
$arrayData['yahoo'][5] = 9; //to ['yahoo'][1]
//googleIndexes parameters
$arrayData['googleIndexes'][0] = "http://www.google.com/
search?hl=en&q=site:$urlI&newwindow=1&filter=0";
$arrayData['googleIndexes'][1] = "of about";
$arrayData['googleIndexes'][2] = "of ";
$arrayData['googleIndexes'][3] = "from ";
$arrayData['googleIndexes'][4] = 3; //to ['googleIndexes'][2]
$arrayData['googleIndexes'][5] = 9; //to ['googleIndexes'][1]
//yahooIndexes parameters
$arrayData['yahooIndexes'][0] = "http://search.yahoo.com/
search?p=$urlI";
$arrayData['yahooIndexes'][1] = "of about";
$arrayData['yahooIndexes'][2] = "of ";
$arrayData['yahooIndexes'][3] = "for ";
$arrayData['yahooIndexes'][4] = 3; //to ['yahooIndexes'][2]
$arrayData['yahooIndexes'][5] = 9; //to ['yahooIndexes'][1]
$path = $arrayData[$engine][0];
if(!@file_exists($path)) {
$data = strtolower(strip_tags(@implode("", @file($path))));
$posI = strpos($data, $arrayData[$engine][1]);
if ($posI > 0) {
$posU = strpos($data, $arrayData[$engine][3]);
if ($posI < $posU) {
$getPos = $posI + $arrayData[$engine][5];
}
else
{
$getPos = strpos($data, $arrayData[$engine][2]) +
$arrayData[$engine][4];
}
}
else
{
$getPos = strpos($data, $arrayData[$engine][2]) +
$arrayData[$engine][4];
}
$data = substr($data, $getPos, strlen($data));
$data = substr($data, 0, strpos($data, " "));
if(@eregi("[[:alpha:]]", $data)) {
$result = "0";
} else {
$result = $data;
}
} else {
$result = "na";
}
return $result;
}
?>
Примеры Для определения количеста ссылок на сайт -
<?php
print GetLinksCount("http://studentsfiles.net","yahoo");
?>
или для google
<?php
print GetLinksCount("http://studentsfiles.net","google");
?>
Для определения индексации сайта в этих поисковых системах:
<?php
print "Indexed of Yahoo - ".GetLinksCount("http://studentsfiles.net","yahooIndexes");
?>
для google
<?php
print "Indexed of Google - ".
GetLinksCount("http://studentsfiles.net","googleIndexes");
?>