espnscrapeR

August 6, 2021 · View on GitHub

The goal of espnscrapeR is to collect or scrape QBR, NFL standings, and stats from ESPN.

Installation

The development version from GitHub with:

# install.packages("remotes")
remotes::install_github("jthomasmock/espnscrapeR")

Example

library(espnscrapeR)
# Get NFL QBR for the 2019 regular season week 4
get_nfl_qbr("2019", season_type = "Regular", week = 4)
#> Scraping weekly QBR for week 4 of 2019!
#> # A tibble: 31 × 29
#>    season season_type game_id   game_week week_text team_abb player_id name_short
#>    <chr>  <chr>       <chr>         <int> <chr>     <chr>    <chr>     <chr>     
#>  1 2019   Regular     401128069         4 Week 4    TB       2969939   J. Winston
#>  2 2019   Regular     401127863         4 Week 4    PHI      2573079   C. Wentz  
#>  3 2019   Regular     401128109         4 Week 4    PIT      3116407   M. Rudolph
#>  4 2019   Regular     401128055         4 Week 4    LAC      5529      P. Rivers 
#>  5 2019   Regular     401128093         4 Week 4    CHI      12471     C. Daniel 
#>  6 2019   Regular     401128102         4 Week 4    DAL      2577417   D. Presco…
#>  7 2019   Regular     401128023         4 Week 4    DET      12483     M. Staffo…
#>  8 2019   Regular     401128097         4 Week 4    DEN      11252     J. Flacco 
#>  9 2019   Regular     401127863         4 Week 4    GB       8439      A. Rodgers
#> 10 2019   Regular     401128018         4 Week 4    CLE      3052587   B. Mayfie…
#> # … with 21 more rows, and 21 more variables: rank <dbl>, qbr_total <dbl>,
#> #   pts_added <dbl>, qb_plays <dbl>, epa_total <dbl>, pass <dbl>, run <dbl>,
#> #   exp_sack <dbl>, penalty <dbl>, qbr_raw <dbl>, sack <dbl>, name_first <chr>,
#> #   name_last <chr>, name_display <chr>, headshot_href <chr>, team <chr>,
#> #   opp_id <chr>, opp_abb <chr>, opp_team <chr>, opp_name <chr>, week_num <int>
# Get NFL standings for 2010
get_nfl_standings(2010)
#> Returning 2010
#> # A tibble: 32 × 28
#>    conf  season team_id team_location team_name team_abb team_full  team_logo   
#>    <chr>  <int> <chr>   <chr>         <chr>     <chr>    <chr>      <chr>       
#>  1 AFC     2010 17      New England   Patriots  NE       New Engla… https://a.e…
#>  2 AFC     2010 23      Pittsburgh    Steelers  PIT      Pittsburg… https://a.e…
#>  3 AFC     2010 33      Baltimore     Ravens    BAL      Baltimore… https://a.e…
#>  4 AFC     2010 20      New York      Jets      NYJ      New York … https://a.e…
#>  5 AFC     2010 11      Indianapolis  Colts     IND      Indianapo… https://a.e…
#>  6 AFC     2010 12      Kansas City   Chiefs    KC       Kansas Ci… https://a.e…
#>  7 AFC     2010 24      San Diego     Chargers  SD       San Diego… https://a.e…
#>  8 AFC     2010 13      Oakland       Raiders   OAK      Oakland R… https://a.e…
#>  9 AFC     2010 30      Jacksonville  Jaguars   JAX      Jacksonvi… https://a.e…
#> 10 AFC     2010 15      Miami         Dolphins  MIA      Miami Dol… https://a.e…
#> # … with 22 more rows, and 20 more variables: seed <int>, wins <dbl>,
#> #   losses <dbl>, win_pct <dbl>, g_behind <dbl>, ties <dbl>, pts_for <dbl>,
#> #   pts_against <dbl>, pts_diff <dbl>, streak <dbl>, div_ties <dbl>,
#> #   record <chr>, home_wins <dbl>, home_losses <dbl>, away_wins <dbl>,
#> #   away_losses <dbl>, conf_wins <dbl>, conf_losses <dbl>, div_wins <dbl>,
#> #   div_losses <dbl>

``$ \text{r}

\text{Get} \text{NFL}

\text{scrape_espn_stats}(2019, \text{stat} = "\text{rushing}") #> \text{Scraping} \text{rushing} \text{stats} \text{from} 2019 \text{Regular} \text{season}! #> # \text{A} \text{tibble}: 335 \times 17 #> \text{season} \text{season_type} \text{rush_rank} \text{name} \text{team} \text{pos} \text{games_played} \text{rush_att} #> <\text{dbl}> <\text{chr}> <\text{int}> <\text{chr}> <\text{chr}> <\text{chr}> <\text{int}> <\text{int}> #> 1 2019 \text{Regular} 1 \text{Derrick} \text{Henry} \text{TEN} \text{RB} 15 303 #> 2 2019 \text{Regular} 2 \text{Nick} \text{Chubb} \text{CLE} \text{RB} 16 298 #> 3 2019 \text{Regular} 3 \text{Christian} \text{McC}… \text{CAR} \text{RB} 16 287 #> 4 2019 \text{Regular} 4 \text{Ezekiel} \text{Ellio}… \text{DAL} \text{RB} 16 301 #> 5 2019 \text{Regular} 5 \text{Chris} \text{Carson} \text{SEA} \text{RB} 15 278 #> 6 2019 \text{Regular} 6 \text{Lamar} \text{Jackson} \text{BAL} \text{QB} 15 176 #> 7 2019 \text{Regular} 7 \text{Leonard} \text{Fourn}… \text{JAX} \text{RB} 15 265 #> 8 2019 \text{Regular} 8 \text{Josh} \text{Jacobs} \text{OAK} \text{RB} 13 242 #> 9 2019 \text{Regular} 9 \text{Joe} \text{Mixon} \text{CIN} \text{RB} 16 278 #> 10 2019 \text{Regular} 10 \text{Dalvin} \text{Cook} \text{MIN} \text{RB} 14 250 #> # … \text{with} 325 \text{more} \text{rows}, \text{and} 9 \text{more} \text{variables}: \text{rush_yards} <\text{dbl}>, \text{rush_avg} <\text{dbl}>, #> # \text{rush_long} <\text{int}>, \text{rush_20plus} <\text{int}>, \text{rush_td} <\text{int}>, \text{rush_yards_game} <\text{dbl}>, #> # \text{fumble} <\text{int}>, \text{fumble_lost} <\text{int}>, \text{rush_first_down} <\text{int}> $``

``$ \text{r}

\text{Get} \text{college} \text{QBR} \text{for} 2014 \text{week} 5

\text{get_college_qbr}(\text{season} = 2014, \text{type} = "\text{weekly}") #> \text{Scraping} \text{QBR} \text{for} \text{all} \text{weeks} \text{of} 2014! #> # \text{A} \text{tibble}: 1{,}610 \times 35 #> \text{season} \text{week} \text{week_text} \text{week_type} \text{player_id} \text{player_uid} \text{player_guid} \text{name_first} #> <\text{int}> <\text{int}> <\text{chr}> <\text{chr}> <\text{chr}> <\text{chr}> <\text{chr}> <\text{chr}>
#> 1 2014 1 \text{Week} 1 \text{Regular} 533208 \text{s}:20~\text{l}:23~… \text{d5b378f113}… \text{Cole}
#> 2 2014 1 \text{Week} 1 \text{Regular} 515409 \text{s}:20~\text{l}:23~… 0467\text{fbf0ba}… \text{Everett}
#> 3 2014 1 \text{Week} 1 \text{Regular} 551184 \text{s}:20~\text{l}:23~… \text{c268152939}… \text{Justin}
#> 4 2014 1 \text{Week} 1 \text{Regular} 513329 \text{s}:20~\text{l}:23~… 3\text{c75884248}… \text{Cody}
#> 5 2014 1 \text{Week} 1 \text{Regular} 511459 \text{s}:20~\text{l}:23~… 33\text{be1f4ad8}… \text{Marcus}
#> 6 2014 1 \text{Week} 1 \text{Regular} 533270 \text{s}:20~\text{l}:23~… 30\text{a818d641}… \text{Tommy}
#> 7 2014 1 \text{Week} 1 \text{Regular} 548240 \text{s}:20~\text{l}:23~… 26507\text{c0b44}… \text{Tyler}
#> 8 2014 1 \text{Week} 1 \text{Regular} 511552 \text{s}:20~\text{l}:23~… \text{ef65357cb9}… \text{Derrius}
#> 9 2014 1 \text{Week} 1 \text{Regular} 504866 \text{s}:20~\text{l}:23~… 61\text{b92d9914}… \text{Brandon}
#> 10 2014 1 \text{Week} 1 \text{Regular} 482594 \text{s}:20~\text{l}:23~… \text{b4348fe9fd}… \text{Taysom}
#> # … \text{with} 1{,}600 \text{more} \text{rows}, \text{and} 27 \text{more} \text{variables}: \text{name_last} <\text{chr}>, #> # \text{name_display} <\text{chr}>, \text{name_short} <\text{chr}>, \text{team_name} <\text{chr}>, #> # \text{team_short_name} <\text{chr}>, \text{slug} <\text{chr}>, \text{team_id} <\text{chr}>, \text{team_uid} <\text{chr}>, #> # \text{age} <\text{int}>, \text{headshot_href} <\text{chr}>, \text{game_id} <\text{chr}>, \text{game_date} <\text{chr}>, #> # \text{player_home_away} <\text{chr}>, \text{score} <\text{chr}>, \text{opp_team_id} <\text{chr}>, #> # \text{opp_team_name} <\text{chr}>, \text{opp_team_short_name} <\text{chr}>, \text{qbr_total} <\text{dbl}>, #> # \text{pts_added} <\text{dbl}>, \text{qb_plays} <\text{dbl}>, \text{epa_total} <\text{dbl}>, \text{pass} <\text{dbl}>, \text{run} <\text{dbl}>, … $``

``$ \text{r}

\text{Get} \text{NFL} \text{teams} \text{with} \text{logos}, \text{colors}, \text{alternatives}, \text{etc}

\text{get_nfl_teams}() #> \text{Getting} \text{NFL} \text{teams}! #> # \text{A} \text{tibble}: 32 \times 8 #> \text{team_id} \text{team_name} \text{team_nickname} \text{team_abb} \text{team_full_name} \text{team_color} #> <\text{chr}> <\text{chr}> <\text{chr}> <\text{chr}> <\text{chr}> <\text{chr}>
#> 1 22 \text{Cardinals} \text{Arizona} \text{ARI} \text{Arizona} \text{Cardinals} #\text{A40227}
#> 2 1 \text{Falcons} \text{Atlanta} \text{ATL} \text{Atlanta} \text{Falcons} #000000
#> 3 33 \text{Ravens} \text{Baltimore} \text{BAL} \text{Baltimore} \text{Ravens} #2\text{B025B}
#> 4 2 \text{Bills} \text{Buffalo} \text{BUF} \text{Buffalo} \text{Bills} #04407\text{F}
#> 5 29 \text{Panthers} \text{Carolina} \text{CAR} \text{Carolina} \text{Panthers} #2177\text{B0}
#> 6 3 \text{Bears} \text{Chicago} \text{CHI} \text{Chicago} \text{Bears} #152644
#> 7 4 \text{Bengals} \text{Cincinnati} \text{CIN} \text{Cincinnati} \text{Bengals} #\text{FF2700}
#> 8 5 \text{Browns} \text{Cleveland} \text{CLE} \text{Cleveland} \text{Browns} #4\text{C230E}
#> 9 6 \text{Cowboys} \text{Dallas} \text{DAL} \text{Dallas} \text{Cowboys} #002\text{E4D}
#> 10 7 \text{Broncos} \text{Denver} \text{DEN} \text{Denver} \text{Broncos} #002\text{E4D}
#> # … \text{with} 22 \text{more} \text{rows}, \text{and} 2 \text{more} \text{variables}: \text{team_alt_color} <\text{chr}>, \text{logo} <\text{chr}> $``