PageRank.py – Get google PageRank with python

I spend several hours trying to find a python script that would return google PageRank with a python script. There seems to be a script out there that was working in 2010 from Corey Goldberg. It is not working for me. I looked around for quite a bit till I found a python script on GitHub. The script is sponsored by Phurix and uses toolbar queries. I decided to republish it with a small modification:

#!/usr/bin/env python

# Google Pagerank Checksum Algorithm (Firefox Toolbar)
# Downloaded from http://pagerank.phurix.net/
# Requires: Python >= 2.4

# Versions:
# pagerank2.py 0.2 - Fixed a minor formatting bug
# pagerank2.py 0.1 - Public release

# Settings
prhost='toolbarqueries.google.com'
prpath='/tbr?client=navclient-auto&ch=%s&features=Rank&q=info:%s'

# Function definitions
def GetHash (query):
    SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer."
    Result = 0x01020345
    for i in range(len(query)) :
        Result ^= ord(SEED[i%len(SEED)]) ^ ord(query[i])
        Result = Result >> 23 | Result << 9
        Result &= 0xffffffff
    return '8%x' % Result

def GetPageRank (query):
    import httplib
    conn = httplib.HTTPConnection(prhost)
    hash = GetHash(query)
    path = prpath % (hash,query)
    conn.request("GET", path)
    response = conn.getresponse()
    data = response.read()
    conn.close()
    return data.split(":")[-1]

if __name__ == "__main__" :
    print GetPageRank("http://schurpf.com/")

I did modify the original script a tiny bit to only return the page rank as a string. That is it. I hope it helps you, let me know comments or questions and I will try to answer as good as I can.

The perfect season to resolve soundness problem is before any visible sign appears. Actually there isn’t anything you can’t purchase on the Internet anymore. Whereas erectile malfunction is more common among older men, that doesn’t some you merely have to live with. What about “canadian pharmacy cialis 5 mg” and “cialis canadian pharmacy“? In our generation, there are divers options for those ones who suffer from erectile malfunction. You may have heard about “canadian pharmacy online cialis“. More info about the problem available at “canadian pharmacy cialis 20mg“. Why it happen? Can sexual disorders in men be prevented? If you get any prescription remedies like Viagra, check with a pharmacist that they are sure to take with your other remedies.

The Top 8 WordPress Developer Tools from 5 years experience
(Hint: They cut down my development time in less than half!)

Get the Top Tools Now!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *