-
Notifications
You must be signed in to change notification settings - Fork 0
/
upworkjson.py
34 lines (26 loc) · 905 Bytes
/
upworkjson.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
import urllib2
import sys
class Players(object):
def __init__(self):
self.data = urllib2.urlopen(
"https://raw.githubusercontent.com/BurntSushi/nflgame/master/nflgame/players.json"
)
self.resp = json.loads(self.data.read())
self.filename = sys.argv[1]
def print_result(self):
with open(self.filename, "a") as f:
for x in self.resp.items():
full_name = x[1][u"full_name"]
try:
team = x[1][u"team"]
except KeyError:
team = "FA"
try:
position = x[1][u"position"]
except KeyError:
position = "unknown"
f.write(u"{} - {} ({})\n".format(full_name, position, team))
if __name__ == "__main__":
players = Players()
players.print_result()