forked from FranGoitia/basketball_reference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatch_generator.py
31 lines (25 loc) · 958 Bytes
/
match_generator.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
import os
import logging, logging.config
import json
from argparse import ArgumentParser
from utils import get_seasons
from nba import NbaBRefSeason
with open('logging.json', 'r') as f:
logging.config.dictConfig(json.load(f))
logger = logging.getLogger('stringer-bell')
def main(league, seasons):
seasons = get_seasons(seasons)
for season in seasons:
path = './matches/{0}/{1}/{2}'.format('united_states', 'nba', season)
if not os.path.exists(path):
os.makedirs(path)
logger.info('Crawling season {0}'.format(season))
b_ref = NbaBRefSeason('united_states', league, season)
b_ref.crawl_season()
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--league', default='nba')
parser.add_argument('--seasons', nargs='+', default=['2014-2015'])
parser.add_argument('--date', default='10')
args = parser.parse_args()
main(args.league, args.seasons)