Created
January 29, 2011 12:51
-
-
Save dwillis/801801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_ncaa_game_xml(game): | |
""" | |
Loader for NCAA game xml files. Accepts a Game object. The NCAA's xml needs to be cleaned up slightly by replacing | |
elements with interior spaces with 0. Some game files contain inaccurate team IDs, mostly for smaller schools, | |
which explains the hard-coding below. On occasion, usually when a team schedules a lower-division opponent, the | |
NCAA may not have have an ID, which will raise an error. | |
>>> game = Game.objects.get(id=793) | |
>>> load_ncaa_game_xml(game) | |
""" | |
doc = urllib.urlopen(game.get_ncaa_xml_url()).read() | |
soup = BeautifulSoup(doc) | |
try: | |
print "trying game # %s: %s-%s" % (game.id, soup.teams.home.orgid.contents[0], soup.teams.visitor.orgid.contents[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment