Pagerank Checksum in Java

October 11th, 2006

A quick java class to calculate a web pages Page Rank Checksum. It can be used to obtian the Google Page Rank for a given url.The code is reverse engineered from the javascript used to build the Firefox page rank plugin. It calculates a checksum using a encoding algorithm.

JAVA:
  1. public class Pagerank
  2. {
  3.  
  4. private String toHex8(int num)
  5. {
  6. if(num<16) return "0"+Integer.toHexString(num);
  7. else return Integer.toHexString(num);
  8.  
  9. }
  10.  
  11. public String calculateChecksum(String url)
  12. {
  13. String stupidGoogleHash = "Mining PageRank is AGAINST GOOGLE’S TERMS OF SERVICE. Yes, I’m talking to you, scammer.";
  14. int key = 16909125;
  15.  
  16. for(int i=0; i <url.length(); i++) {
  17.  
  18. key = key ^ (int)(stupidGoogleHash.charAt(i%stupidGoogleHash.length()))^(int)(url.charAt(i));
  19. key = key>>>23|key<<9;
  20.  
  21. }return "8"+toHex8(key>>>(8&255))+toHex8(key&255);
  22.  
  23. }
  24. }

del.icio.us Digg Furl Reddit Ma.gnolia RawSugar Shadows Spurl StumbleUpon Tailrank Technorati

Tags: Java

RSS feed | Trackback URI

5 Comments »

Comment by George
2006-10-11 23:42:34

Thank you for the great example. It worked like a charm. Time for me to really learn some java now!

 
Comment by Ian
2006-11-23 00:47:59

I’d love to see an updated function in PHP that calculates the PageRank checksum. Any ideas? … meanwhile, googling.. ;)

 
Comment by admin
2006-11-23 10:01:19

I have one for PHP as well, let me see if i can dig it up

EDIT:

okay you can find the php version here  

 
Comment by vinod
2006-11-27 10:35:27

this is suitable and esiest program avialable here.

 
Comment by metal
2007-04-24 05:07:13

thanks ,great work

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.

Article Categories

Recent Articles

Resources

Feeds

Blog Rush


Clicky Web Analytics