I was also trying to fine my rank, but since I am not Jon Skeet or Marc Gravell it involves a lot of clicking through pages for me. Since I started learning Python I typed together a little script which would do the clicking for me. If you are a low reputation user like I am, it takes quiet a while. When asked for user id, type in the number from the url when going on your profile
|
v
http://stackoverflow.com/users/74660/lucas
Enjoy:
import urllib.request
import re
from html.parser import HTMLParser
class UserParser(HTMLParser):
counter = 0
userid = 0
result = 0
found = False
def handle_starttag(self, tag, attrs):
if tag == 'a':
for name, value in attrs:
m = re.search('^/users/(\d+)/(.*)',value)
if name == 'href' and m:
self.counter = self.counter + 1
if 0 == self.counter%2:
string = str(self.counter//2)+ ':\t' + m.group(1) + '\t' + m.group(2)
if m.group(1) == str(self.userid):
self.found = True
self.result = self.counter//2
print(string)
if __name__ == '__main__':
opener = urllib.request.FancyURLopener({})
parse = UserParser()
parse.userid = input('Please enter your user id:')
url = "http://stackoverflow.com/users?page=" + str(1)
f = opener.open(url)
content = f.read()
i = 2
parse.feed(content.decode("utf-8"))
while (not parse.found):
url = "http://stackoverflow.com/users?page=" + str(i)
f = opener.open(url)
content = f.read()
parse.feed(content.decode("utf-8"))
i = i + 1
print("********Found*********")
print(str(parse.userid) + " found at "+ str(parse.result))
Not exactly pretty but it works good enough for me ... (I have low standards)