Author Topic: Get Alexa Rank using Php  (Read 3424 times)

bbasujon

  • Administrator
  • VIP Member
  • *****
  • Posts: 1827
  • I want to show my performance at any where
    • View Profile
    • Higher Education
Get Alexa Rank using Php
« 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
Acquire the knowledge and share the knowledge so that knowing,learning then sharing - all are the collection