Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limit issue with "bref_standings_on_date" #344

Open
cregger25 opened this issue Jun 29, 2024 · 1 comment
Open

Rate limit issue with "bref_standings_on_date" #344

cregger25 opened this issue Jun 29, 2024 · 1 comment

Comments

@cregger25
Copy link

I'm running into an issue when I try to run a script with the following code:

AL_East <- bref_standings_on_date(Sys.Date(), division = "AL East", from = FALSE)
AL_Central <- bref_standings_on_date(Sys.Date(), division = "AL Central", from = FALSE)
AL_West <- bref_standings_on_date(Sys.Date(), division = "AL West", from = FALSE)
NL_East <- bref_standings_on_date(Sys.Date(), division = "NL East", from = FALSE)
NL_Central <- bref_standings_on_date(Sys.Date(), division = "NL Central", from = FALSE)
NL_West <- bref_standings_on_date(Sys.Date(), division = "NL West", from = FALSE)

When trying to run this code I get the following error
2024-06-29 10:34:08.684472: Invalid arguments or no standings on date data available!
Error in bref_standings_on_date(Sys.Date(), division = "NL East", from = FALSE) :
object 'x' not found

If I try running the script again I get:
2024-06-29 10:34:08.684472: Invalid arguments or no standings on date data available!
Error in bref_standings_on_date(Sys.Date(), division = "AL East", from = FALSE) :
object 'x' not found

I tried the code on the postit.cloud interface and it seemed to work fine. So I uninstalled baseballr and reinstalled it. Made sure my R/Rstudio were both up to date(they were). Still didn't work.

So then I went into the bref_standings_on_date function and tried running it step by step to see where I was getting hung up. Turns out I was getting this error:
Error in open.connection(x, "rb") : HTTP error 429

I don't consider myself too knowledgeable about these things, but it seems that code means I'm getting rate limited by Baseball ref. I've run this script with this block of code every morning of the baseball season for the last 2.5 years. Any idea why I'm starting to get rate limited now? I only run it in the morning, so it's not like I'm running it all the time.

I understand I can add a Sys.sleep() inbetween each one to help with not getting rate limited. What is a good amount of time to put in the Sys.sleep so baseball ref doesn't get mad at me. Is there a better way to go about doing this?

Running macOS 13.6.3, R 4.4.1, Rstudio 2024.04.2+764.

Any tips would be appreciated, Thanks!

@SShaw14
Copy link

SShaw14 commented Aug 29, 2024

I have the exact same issue. Does anyone have a solution? Also happens with standings_on_date_bref. I run the example code lines from the website and they all crash with "Error in standings_on_date_bref(todays_date, this_div, from = FALSE) :
object 'x' not found"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants