PHP Code, SEO Optimization

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

7 Comments

  1. 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. 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. 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. nice script but…
    it doesn't work properly. Tried and does not always return correct page rank/ratings et al (if any).

  5. lenutaa_mirceaa

    a web technology,programming and seo blog by justin-cook.

  6. de script dont work, de error curl lib not, found, so who to added Curl on server

  7. Hey there this is kinda of off topic but I was wondering if
    blogs use WYSIWYG editors or if you have to manually
    code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
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.
Anti-spam image