BillPetti / baseballr

A package written for R focused on baseball analysis. Currently in development.
billpetti.github.io/baseballr
Other
369 stars 99 forks source link

2021 College Stats #188

Closed Mattf18 closed 3 years ago

Mattf18 commented 3 years ago

Hi,

When trying to scrape 2021 college stats, I get the following error:

My code: AMCorpusChristiHit21 <- ncaa_scrape(26172,2021, "batting")

Error: Error in open.connection(x, "rb") : HTTP error 404.

I've went back and updated all relevant packages and noticed that 2020 stats scraped fine. Was curious if there was anything else I can do on my end to get this right.

Thanks!

BillPetti commented 3 years ago

Hmm, works fine for me. That error usually indicates a bad url or internet connection. Have you been scraping the NCAA a lot? Could also be a temporary ban of your IP address. Check if you can access https://stats.ncaa.org from your browser to check.

> ncaa_scrape(26172,2021, "batting")
   year             school conference division Jersey                Player Yr Pos GP GS    BA
1  2021 A&M-Corpus Christi  Southland        1     11 Rivera-Chijin, Steven Sr  SS  9  8 0.227
2  2021 A&M-Corpus Christi  Southland        1      4        Johnson, Diego Fr INF  9  6 0.111
3  2021 A&M-Corpus Christi  Southland        1      1          Burts, Itchy Sr  OF  9  9 0.226
4  2021 A&M-Corpus Christi  Southland        1     24        Williams, Mike Sr  OF  9  9 0.242
5  2021 A&M-Corpus Christi  Southland        1     18         Markotic, Leo So  2B  9  8 0.296
6  2021 A&M-Corpus Christi  Southland        1     13         Caraway, Josh Fr   C  8  8 0.207
7  2021 A&M-Corpus Christi  Southland        1     15        Welch, Tristan Jr  OF  8  7 0.261
8  2021 A&M-Corpus Christi  Southland        1     10         Ryan, Brendan So INF  6  2 0.375
9  2021 A&M-Corpus Christi  Southland        1     16       Hastings, Scott Sr  1B  6  5 0.111
10 2021 A&M-Corpus Christi  Southland        1      2         Marbach, Luke Sr  1B  6  5 0.571
11 2021 A&M-Corpus Christi  Southland        1      3            Jones, Tre Fr  OF  6  4 0.231
12 2021 A&M-Corpus Christi  Southland        1     23           White, Nate Fr INF  5  2 0.333
13 2021 A&M-Corpus Christi  Southland        1     28           Byrd, Tyler Fr   C  5  2 0.222
14 2021 A&M-Corpus Christi  Southland        1     27          Shy, Cassius Jr   P  5 NA    NA
15 2021 A&M-Corpus Christi  Southland        1     33        Nelson, Daniel Jr   P  4 NA    NA
16 2021 A&M-Corpus Christi  Southland        1     39      Petkoff, Brandon Fr  OF  4  1 0.250
17 2021 A&M-Corpus Christi  Southland        1      7           Bird, Henry Jr   P  3  2    NA
18 2021 A&M-Corpus Christi  Southland        1     32         Lewis, Justin So   P  3 NA    NA
19 2021 A&M-Corpus Christi  Southland        1     29        Purcell, Colin Fr   P  3 NA    NA
20 2021 A&M-Corpus Christi  Southland        1     43           Moeller, JT Fr   P  3 NA    NA
21 2021 A&M-Corpus Christi  Southland        1     31         Perez, Leonel Jr   P  3  3    NA
22 2021 A&M-Corpus Christi  Southland        1     21        Taylor, Justin So   C  3  3 0.222
23 2021 A&M-Corpus Christi  Southland        1     17        Hopkins, Mason So   P  2 NA    NA
24 2021 A&M-Corpus Christi  Southland        1     26        Johnson, Dylan Fr   P  2 NA    NA
25 2021 A&M-Corpus Christi  Southland        1      9            Lopez, Dom Fr   P  2 NA    NA
26 2021 A&M-Corpus Christi  Southland        1     22    Ramirez Jr., Jaime Fr   P  2  1    NA
27 2021 A&M-Corpus Christi  Southland        1     36         Miller, Tyler So   P  2 NA    NA
28 2021 A&M-Corpus Christi  Southland        1     30        Urbantke, Nick Sr   P  2  1    NA
   OBPct SlgPct  R AB  H 2B 3B TB HR RBI BB HBP SF SH  K DP CS Picked SB RBI2out teamid
1  0.469  0.318  5 22  5 NA  1  7 NA  NA  5   5 NA NA  4 NA NA      1 NA      NA  26172
2  0.273  0.111  3 18  2 NA NA  2 NA   1  4  NA NA NA  3 NA NA      1 NA      NA  26172
3  0.342  0.258  3 31  7  1 NA  8 NA   5  6  NA  1 NA  3  1 NA     NA  2      NA  26172
4  0.306  0.364  4 33  8  1 NA 12  1   5  2   1 NA NA  7  1 NA     NA NA      NA  26172
5  0.406  0.333  2 27  8  1 NA  9 NA   3  3   2 NA NA  6 NA NA      1 NA      NA  26172
6  0.324  0.621  6 29  6  1  1 18  3   4  2   3 NA NA  8  2 NA     NA NA      NA  26172
7  0.333  0.261  2 23  6 NA NA  6 NA   2  2   1  1 NA  7 NA NA      1  2      NA  26172
8  0.500  0.375  1  8  3 NA NA  3 NA  NA  2  NA NA NA  5 NA  1     NA NA      NA  26172
9  0.217  0.111  1 18  2 NA NA  2 NA   2  2   1  2 NA  1  4  1      1 NA      NA  26172
10 0.632  1.071  6 14  8  4 NA 15  1   6  3   1  1 NA  2 NA  1     NA  2      NA  26172
11 0.333  0.462  1 13  3 NA NA  6  1   4  2  NA NA NA  3 NA NA     NA NA      NA  26172
12 0.600  0.333  1  3  1 NA NA  1 NA  NA  2  NA NA NA  2 NA  1     NA  1      NA  26172
13 0.300  0.222  1  9  2 NA NA  2 NA  NA  1  NA NA NA  5 NA NA     NA NA      NA  26172
14    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
15    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
16 0.400  0.375 NA  8  2  1 NA  3 NA  NA  2  NA NA  1  2 NA NA     NA NA      NA  26172
17    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
18    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
19    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
20    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
21    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
22 0.300  0.333 NA  9  2  1 NA  3 NA  NA  1  NA NA NA  2 NA  1     NA NA      NA  26172
23    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
24    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
25    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
26    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
27    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
28    NA     NA NA NA NA NA NA  0 NA  NA NA  NA NA NA NA NA NA     NA NA      NA  26172
   conference_id player_id
1            914   1998349
2            914   2320565
3            914   1884356
4            914   2139614
5            914   2492952
6            914   2492951
7            914   2320575
8            914   2492948
9            914   2139615
10           914   1884359
11           914   2320567
12           914   2320576
13           914   2492966
14           914   2320572
15           914   2320547
16           914   2320571
17           914   2320561
18           914   2320569
19           914   2492968
20           914   2492995
21           914   1998284
22           914   2139616
23           914   2139620
24           914   2320566
25           914   2139618
26           914   2320577
27           914   2139591
28           914   2120149
Mattf18 commented 3 years ago

I think it turned out to be an internet connection issue, but I've got it running. Thank you for the quick reply!

AlexGouv commented 3 years ago

Hi,

I am getting the same error for 2021 data only. @Mattf18 can you share what fixed the issue for you? Another strange thing I notcied is that when I use 'school_id_lu' I do not get any results for 2021.

`> baseballr::school_id_lu('La Salle')

A tibble: 7 x 6

school conference school_id year division conference_id

1 La Salle Atlantic 10 340 2013 1 820 2 La Salle Atlantic 10 340 2014 1 820 3 La Salle Atlantic 10 340 2015 1 820 4 La Salle Atlantic 10 340 2016 1 820 5 La Salle Atlantic 10 340 2017 1 820 6 La Salle Atlantic 10 340 2018 1 820 7 La Salle Atlantic 10 340 2020 1 820` Thanks!