from BeautifulSoup import BeautifulSoup from urllib2 import urlopen import re SOURCE = 'http://code.google.com/p/macvim/downloads/list?%s&%s' % ( 'can=1', # show all files 'colspec=Filename+DownloadCount') # we only need name and download count NAMES_ATTRIBS = {'class' : re.compile(r'col_0$') } COUNTS_ATTRIBS = {'class' : re.compile(r'col_1$') } def fetchNewColumn(): soup = BeautifulSoup(urlopen(SOURCE)) resultstable = soup.find('table', id='resultstable') names = [str(x.a.string) for x in resultstable.findAll('td', NAMES_ATTRIBS)] counts = [int(x.a.string) for x in resultstable.findAll('td', COUNTS_ATTRIBS)] return dict(zip(names, counts))