def fg_playerid(args): from .fangraphs import fg_player_alphabet_links,fg_player_ids print('scraping fangraphs player ids',file=sys.stderr) alinks = [*fg_player_alphabet_links()] print('fgid,player_name,position,first_year,last_year',file=sys.stdout) for link in ProgBar().iter(alinks): for l in fg_player_ids(link): print(l,file=sys.stdout)
def fg_parkfactor(args): from .fangraphs import fg_park_factors print('scraping fangraphs parkfactors',file=sys.stderr) prog = ProgBar().iter(args.years) for l in fg_park_factors(next(prog)): print(l,file=sys.stdout) for year in prog: tbl = iter(fg_park_factors(year)) next(tbl) for l in tbl: print(l,file=sys.stdout)
def bbr_teamid(args): from .baseball_reference import bbr_teamids_year print("scraping teamids from baseball-reference.com",file=sys.stderr) prog = ProgBar().iter(args.years) for l in bbr_teamids_year(next(prog)): print(l,file=sys.stdout) for year in prog: tbl = iter(bbr_teamids_year(year)) next(tbl) for l in tbl: print(l,file=sys.stdout)
def fg_advbat(args): from .fangraphs import fg_playerkeys,fg_advanced_batting keys = fg_playerkeys(args.years) print('scraping fangraphs advance batting',file=sys.stderr) prog = ProgBar().iter(keys) for l in fg_advanced_batting(*next(prog),args.years): print(l,file=sys.stdout) for fgid,pos in prog: tbl = iter(fg_advanced_batting(fgid,pos,args.years)) next(tbl) for l in tbl: print(l,file=sys.stdout)
def sr_playertable(args): from .spotrac import spotrac_keys,spotrac_playertable keys = [*spotrac_keys(args.years)] print('scraping spotrac playertables',file=sys.stderr) prog = ProgBar().iter(keys) for l in spotrac_playertable(*next(prog)): print(l,file=sys.stdout) for year,team,url in prog: tbl = iter(spotrac_playertable(year,team,url)) next(tbl) for l in tbl: print(l,file=sys.stdout)
def bbr_salary(args): from .baseball_reference import bbr_teamkeys,bbr_salary_table if args.team == None and args.years==None: print("Error: Need to provide at least a team(s) -t <team> or a year(s) -y <year> to scrape data from",file=sys.stderr) return keys = bbr_teamkeys(team=args.team,year=args.years) print("scraping salary tables from baseball-reference.com",file=sys.stderr) prog = ProgBar().iter(keys) for l in bbr_salary_table(*next(prog)): print(l,file=sys.stdout) for year,team in prog: tbl = iter(bbr_salary_table(year,team)) next(tbl) for l in tbl: print(l,file=sys.stdout)