scraper.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:sportsball 作者: jgershen 项目源码 文件源码
def update_players(year=None):
  year_to_update = year
  if not year_to_update:
    year_to_update = datetime.date.today().year
    if datetime.date.today().month > 8: # it's really the 201X-201(x+1) season, we should use x+1 as year
      year_to_update += 1
  logging.info("update_players: Loading all stats for new players and re-examining stats from %d" % year_to_update)
  scrape_overview_for_new_players()
  players = load_overview_dict()
  players = load_dataframes(players)
  # Identify players we know of, but haven't loaded full stats for.
  # This will include any players we just found with scrape_overview_for_new_players.
  players_to_load = [p for p in players if 'gamelog_data' not in players[p]]
  if players_to_load:
    logging.info("update_players: loading first-time stats for %d players", len(players_to_load))
    pbar = progressbar.ProgressBar(widgets=[progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.ETA()])
    for player in pbar(players_to_load):
      logging.info('update_players: loading first-time stats for %s', player)
      players = load_player(players, player)
  pbar = progressbar.ProgressBar(widgets=[progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.ETA()])
  for player in pbar(players.keys()):
    # found name, load player data
    logging.info('update_players: updating player data for %s...', player)
    players = update_player(players, player, year=year_to_update)
  save_dataframes(players)
  update_mapping_df(players)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号