Search This Blog

Monday, January 11, 2010

Calculate Google Page Rank with Flex/AIR

While working on the development of an SEO tool in AIR, I needed to calculate Google Page Rank for a website with given URL.
This article was what I started with. But mimicking the hashing algorithm developed by Bob Jenkins from C# to ActionScript was not a good idea that my deadlines could allow.

I still Googled and fortunately found this one. Here is a summary of the article from Louis Lee (not sure he's the original author).

  1. Download FetchPR.as
  2. Add it to your project.
  3. Initialize the FetchPR’s instance.
  4. Set the callback function of FetchPR
  5. Call FetchPR’s getPR function to get a url’s PR.
Sample code

import scripts.FetchPR;
import mx.managers.CursorManager;
private var fetchprinstance:FetchPR = new FetchPR();

private function getPageRank():void
{
CursorManager.setBusyCursor();
fetchprinstance.callback = setResult;
fetchprinstance.getPR(urlbox.text);
}

public function setResult(pr:Number):void
{
result.text = "PageRank is: " + pr.toString();
CursorManager.removeBusyCursor();
}

No comments:

Post a Comment