Daffodil Computers Ltd.

Create your Own Website => Website development => Topic started by: bbasujon on February 09, 2012, 09:32:01 AM

Title: Get Alexa Rank using Php
Post by: bbasujon on February 09, 2012, 09:32:01 AM
Here is a simple PHP script to get the Alexa Rank of any website. This script can be used to display the Alexa Rank without any widget or plugin.

Some people tend to enter the Alexa Rank in About Us page, but since the rank keeps changing they got to update it often, I see some sites in Blogosphere where people hardly edit the Alexa Rank, such cases, this PHP script can dynamically generate the accurate present Alexa Rank

PHP Code for Alexa Rank

    <?php
    $url = ‘bytechip.com’;
    $new_url = ‘http://www.alexa.com/siteinfo/’.$url;
    $contents=file_get_contents($new_url);

    /* This will find the Global Alexa Rank */
    $start = strpos($contents, “<div class=”data up”>”) +119;
    $stop= strpos($contents,”<div class=”label”>Alexa Traffic Rank”);
    $result = substr($contents,$start,$stop-$start);
    echo “Global Alexa Rank for “.$url.” = “.$result;
    ?>

moz screenshot Get Alexa Rank using Php
Download Alexa Rank PHP Script:
http://rapidshare.com/files/379534454/alexa.php.html