• Feed

  • Sponsors

  • Clicky Ranking

    31905
    Ranking by getClicky.com

  • « Make Money online | Main | MyBlogLog »

    Get Alexa Ranking with PHP

    By maurizio | May 17, 2007

    If you are new here, you may want to subscribe to my RSS feed. Feel free to leave comments and questions too.Thanks for visiting!

    I finally added caching to my Alexa function in PHP. First I have to say that this is not the best way to do that. I created this script without getting any information on how to retrieve my Ranking. I decided to create it when I discovered how dumb was Alexa’s code. I just wanted to copy my ranking on a text, just to see how worse it could become, but I discovered that wasn’t easy to do because of the <span> here and there.
    This script is a good way to continue learning PHP. I already wrote how to get Alexa’s ranking with PHP and how to cache a php script; now you can download both things together. Please note that I cache just a number, so you shouldn’t use it with 2 different sites.You can do that, but you have to modify some parts of the code and use two different scripts.
    To use it you just have to include my file and call nafurai_print_alexa_rank(your_url).
    This is my rank: 1,510,520 :(
    I know it’s very low :(

    Before you flame me with emails, I have to tell you a few things (but you can still flame me..better than no emails at all :-) )

    1. Alexa has his own Programming interface to access those datas. They have a special API to access those info. If you have a small site, you shouldn’t pay for it.If you have a big one, you pay a small amount for every query (question) you make to their server.
    2. There is another way to do that which is similar to mine but uses another file instead of the resulting html page that everyone sees. This method involve opening a XML file you can get from their server which is easier to read. I didn’t know about it so I just finished my way to read it. I am not even sure that this method is allowed for everyone.I think it should be the same as the point above, but Alexa isn’t checking who’s reading it. If they stop giving away that file, my method is the only one
    3. If Alexa change some small pieces of their HTML page, we should check my code and correct it accordingly.

    If you see a cache.txt file on the root of your site, don’t worry..that’s my cache.

    Download here.

    Topics: Content Creation, Programming |

    Read other related posts:

  • Alexa ranking in PHP again
  • My Alexa ranking is rising
  • Increase Alexa rank
  • 5 Responses to “Get Alexa Ranking with PHP”

    1. Alexa ranking in PHP again | Nafurai Says: MyAvatars 0.2
      May 21st, 2007 at 11:51 pm

      [...] Get Alexa Ranking with PHP [...]

    2. Winter Says: MyAvatars 0.2
      May 23rd, 2007 at 8:03 pm

      Thanks so much for your intructions, I get alexa traffic at last.

    3. Blog Research is online! | Nafurai Says: MyAvatars 0.2
      September 10th, 2007 at 3:23 am

      [...] Get Alexa Ranking with PHP [...]

    4. Adam Says: MyAvatars 0.2
      December 12th, 2007 at 5:11 pm

      That’s such a verbose file. Have you never heard of regular expressions? It would have saved you so much time, easier on the fingers, and possibly even quicker, too.

      You went about it the same way as me though! How silly of Alexa not to dynamically create the CSS document on-the-fly. Even if they did though, we’d both just grab it every time and have more of an impact on their bandwidth :)

      Damn we’re cheap-skates!

    5. Otel Tatil Says: MyAvatars 0.2
      July 19th, 2008 at 1:52 am

      thanks for instructions

    Comments

    Subscribe without commenting