Skip to content

Instantly share code, notes, and snippets.

@LucasArruda
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucasArruda/e3bc8db811ec51f54fa3 to your computer and use it in GitHub Desktop.
Save LucasArruda/e3bc8db811ec51f54fa3 to your computer and use it in GitHub Desktop.
World Cup 2014 results on terminal
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