December 28th, 2006

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.


<?php
/*
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);

?>
  • Share/Bookmark

4 Responses to ' Check Alexa PageRank, Google/MSN/Yahoo Backlinks '

Subscribe to comments with RSS or TrackBack to ' Check Alexa PageRank, Google/MSN/Yahoo Backlinks '.


  1. 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.

  2. lamorozzo said,

    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

  3. hzgames said,

    on June 25th, 2008 at 9:51 pm

    runescape gold
    runescape money
    warhammer gold
    Warhammer Online Gold

    [url=http://www.hzgames.com]runescape gold[/url]
    [url=http://www.hzgames.com]runescape money[/url]
    [url=http://www.hzgames.com/news.asp]warhammer gold[/url]
    [url=http://www.hzgames.com/news.asp]Warhammer Online Gold[/url]

  4. TED said,

    on May 11th, 2009 at 1:50 pm

    nice script but…
    it doesn't work properly. Tried and does not always return correct page rank/ratings et al (if any).

Leave a reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word