Check Alexa PageRank, Google/MSN/Yahoo Backlinks
Here is a PHP code snippet that will allow you to check the Alexa rank, and the number of inbound links in Google, MSN and Yahoo search engines.
All you need to do is set the $url variable, which you can do by posting from a form, or perhaps including it in the querystring.
/*
Function to check Alexa rank
*/
function get_alexa($url){
$site = fopen('http://www.alexa.com/data/details/main?url='.urlencode($url),'r');
while($cont = fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression = '/for more information about the Alexa Web Information Service.–>(.*)<\/span><\/a>/Us';
preg_match($match_expression,$total,$matches);
return strip_tags($matches[1]);
}
/*
Function to check Google Backlinks
*/
function google_backs($url){
$site = fopen('http://www.google.com/search?q=link%3A'.urlencode($url),'r');
while($cont = fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression = '/of about <b>(.*)<\/b> linking to/Us';
preg_match($match_expression,$total,$matches);
return $matches[1];
}
/*
Functin to check MSN Backlinks
*/
function msn_backs($url){
$site = fopen('http://search.live.com/results.aspx?q=link%3A'.urlencode($url),'r');
while($cont = fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression = '/<h5>Page 1 of (.*) results<\/h5>/Us';
preg_match($match_expression,$total,$matches);
return $matches[1];
}
/*
Function to check Yahoo Backlinks (Called inlinks)
*/
function yahoo_backs($url){
$site = fopen('http://siteexplorer.search.yahoo.com/search?p='.urlencode($url).'&bwm=i&bwmf=a&bwms=p','r');
while($cont = fread($site,1024657)){
$total .= $cont;
}
fclose($site);
$match_expression = '/of about <strong>(.*) <\/strong>/Us';
preg_match($match_expression,$total,$matches);
return $matches[1];
}
/*
Example Usage:
*/
$link = 'http://www.google.com';
echo "URL: $link, Has ". get_alexa($link).' Alexa Rank, Google BackLinks: '.google_backs($link).' - MSN BackLinks '.msn_backs($link).' Yahoo BackLinks: '.yahoo_backs($link);
?>

on March 22nd, 2007 at 7:44 am
BackLinkBot - a system for searching for, check and ranking the inverse references. Available searching for on Aport, Mail, Rambler, Yandex, Google, Lycos, MSN, Yahoo. Work from localhost and with server Unix. Quick algorithms of the work, minimum load to system.
on April 17th, 2007 at 1:18 pm
I found too much scripts and web references in search engines (google, yahoo, alltheweb and others forums) proposing this solution.
I test it on a Windows Platform with EasyPHP and found some bugs
- not allways alexa returns the wanted values for Traffic Rank
- not allways MSN returns the wanted values for back links
- not allways Google returns the wanted values for back links
etc,,,
some responses will be transmitted by email