BillPetti/baseballr

fg_team_pitcher function does not work

Opened this issue · 5 comments

fg_team_pitcher does not work, returning the issue:

2023-08-13 10:22:28: Invalid arguments or no team data available!
Error in fg_team_pitcher(x = 2015, y = 2015, qual = 150) :
object 'leaders' not found

It looks like this was an issue recently due to something that changed on fangraphs' end.

I'm having the same error with fg_bat_leaders() and fg_pitch_leaders() functions.

I did an uninstall and reinstall of baseballr yesterday, which fixed it. Then, this morning, I'm having the same issue.

Believe it's something wrong with 'table.rgMasterTable' here that changed on Fangraph's end. I didn't have time to look into what the proper html_element would be instead, the few I tried quickly returned empty tables.

        leaders <- payload %>%
          rvest::html_elements("table.rgMasterTable") %>% 
          rvest::html_table()

I'll take a look tonight and see what the issue is.

FanGraphs put out something earlier this year saying they'll be changing their site around which would ultimately result in scrapers not working for their leaderboards (though they'll have another page that matched the old style but that page also wouldn't last forever)

I hope there's a workable solution! I just built a next stage of a project I have been building out based on the pitching leaderboards, so would be painful to see it go. Manual fangraph csv exports might work for me, though it won't be ideal.