Scrape ESPN fantasy football scores

scrape_espn_ff_scores(
  league_id = .get_league_id(),
  league_size = .get_league_size(),
  season = .get_season(),
  weeks = .get_weeks_cutoff(),
  local = FALSE,
  path_teams = NULL,
  path_scores = NULL,
  ...,
  overwrite = FALSE,
  export = TRUE,
  dir = .get_dir_data(),
  file = .generate_espn_ff_scores_file(league_id, league_size, season, weeks),
  ext = "csv",
  path = file.path(dir, sprintf("%s.%s", file, ext)),
  f_import = readr::read_csv,
  f_export = readr::write_csv
)

Arguments

league_id

Number for ESPN league. Probably 6 digits. Can be set globally in the options. See ffsched.league_id.

league_size

Number of teams in the league. Can be set globally in the options. See ffsched.league_size.

season

Season for which to scrape. Can be set globally in the options. See ffsched.season.

weeks

How many weeks are in schedule. Presently, this function requires that (league_size - 1) <= weeks < (2 * (league_size - 2)).

local, path_teams, path_scores

If your league is not public, you will have to download the appropriate JSON files, set local = TRUE, and point path_teams and path_scores to these JSON files. The JSON for path_teams should downloaded from http://fantasy.espn.com/apis/v3/games/ffl/seasons/{season}/segments/0/leagues/{league_id}?view=mtm and the JSON for path_scores should be downloaded from http://fantasy.espn.com/apis/v3/games/ffl/seasons/{season}/segments/0/leagues/{league_id}?view=mMatchup.

...

Additional parameters passed to generate_schedule()

overwrite

Whether to overwrite existing file at path, if it exists.

export

Whether to export.

dir

Directory to use to generate path if path is not explicitly provided.

file

Filename (without extension) to generate path if path is not explicitly provided.

ext

File extension to use to generate path if path is not explicitly provided.

path

Path to export to.

f_import

Function to import with if file exists and overwrite = TRUE.

f_export

Function to export with if export = TRUE .

See also