Masi Masi - 4 months ago 14
Python Question

To build a similar reputation tracker as Jon's by Python

Jon Skeet has the following reputation tracker which is built by C#.

I am interested in building a similar app by Python such that at least the following modules are used


  • beautiful soup

  • defaultdict



We apparently need



How can you build a similar reputation system as Jon's one by Python?

Answer

The screenscraping is easy, if I understand the SO HTML format correctly, e.g., to get my rep (as I'm user 95810):

import urllib
import BeautifulSoup
page = urllib.urlopen('http://stackoverflow.com/users/95810')
soup = BeautifulSoup.BeautifulSoup(page)
therep = str(soup.find(text='Reputation').parent.previous.previous).strip()
print int(therep.replace(',',''))

I'm not sure what you want to do with defaultdict here, though -- what further processing do you desire to perform on this int, that would somehow require storing it in a defaultdict?