12

This small python script outputs a small version of the current Barclays Premier League (2011-12 season).

Save it somewhere as premierleague.py and then run it from a script within Geektool (with a fixed-width font)

Edit: To run the script, use the command "python /Users/username/premierleague.py" (or wherever you've saved it).

#!/usr/bin/python

import urllib2
from xml.dom.minidom import parseString

hometeam="Liverpool" # Replace this with your team

url="http://www.premierleague.com/rss/ptv/page/LeagueTable/0,,12306~2231392,00.xml"

file = urllib2.urlopen(url)
data = file.read()
file.close()
data = data.replace(hometeam, hometeam.upper())

#parse xml
dom = parseString(data)

print "POS CLUB                 PLD   GD PTS"

#loop through <entry> elements
entry=dom.getElementsByTagName('entry')
for node in entry:
    position=node.getAttribute('position')
    name=node.getAttribute('name')
    played=node.getAttribute('played')
    goalDifference=node.getAttribute('goalDifference')
    points=node.getAttribute('points')

    #print position, name, played, goalDifference, points
    print "%3s %-20s %3s %4s %3s" % (position, name, played, goalDifference, points)

Geeklet files to download

Comments

Log in to comment or register here.