Last active
August 29, 2015 14:02
-
-
Save LucasArruda/e3bc8db811ec51f54fa3 to your computer and use it in GitHub Desktop.
World Cup 2014 results on terminal
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
from urllib2 import urlopen | |
import json | |
resp = urlopen('http://worldcup.sfg.io/matches/?by_date=DESC').read() | |
for jogo in json.loads(resp): | |
complete = (jogo['status'] == 'completed') | |
current = (jogo['status'] == 'in progress') | |
if complete or current: | |
ht = jogo['home_team'] | |
home = ht['country'] | |
hCode = ht['code'] | |
hScore = ht['goals'] | |
at = jogo['away_team'] | |
away = at['country'] | |
aCode = at['code'] | |
aScore = at['goals'] | |
# default print | |
#print home,hScore,'x',aScore,away | |
# country full names | |
#print "%s %dx%d %s" % (home,hScore,aScore,away), | |
# country codes | |
print "%s %dx%d %s" % (hCode,hScore,aScore,aCode), | |
# mark 'in progress' games | |
print '*' if current else '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment