4

Spanish Football - La Liga

Posted in Internet by finster 260 days ago

Here's a script to show a summary of La Liga. Save it somewhere (such as Documents/laliga.py).

Use the command "python /Users/xxxx/Documents/laliga.py" to run it.

#!/usr/bin/python

import urllib2
from xml.dom.minidom import parseString

hometeam="Barcelona" # Replace this with your team

url="http://www.footbo.com/widgets/xml/LeagueTable.aspx?id=193770"

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('LeagueTableRow')
for node in entry:
    position=node.getAttribute('Position')
    name=node.getAttribute('TeamName')
    played=node.getAttribute('GamesPlayed')
    goalDifference=node.getAttribute('GoalsDifference')
    points=node.getAttribute('Points')

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

Geeklet files to download

Comments

Log in to comment or register here.