baseballr icon indicating copy to clipboard operation
baseballr copied to clipboard

bref_team_results() returns no data

Open darrenpage15 opened this issue 3 years ago • 1 comments

The bref_team_results() function results in the error message: "Invalid arguments or no team results data available!"

Example code: bref_team_results("MIN", 2022)

Other functions that pull data from baseball reference fail as well.

darrenpage15 avatar Aug 28 '22 21:08 darrenpage15

I wonder if this is the same issue I'm hitting with standings_on_date_bref(), as I receive the same error. When I replicate the internals of the method, it looks like this error is caught and a variation on the error you received is returned:

> url %>% xml2::read_html()
Error in open.connection(x, "rb") : HTTP error 403.

Since 403 means forbidden, I tried with various user agents, (i.e. httr::set_config(httr::user_agent("[email protected]")) including some that showed as allow all under b-ref's robotx.txt, but now I'm just getting timeouts, suggesting I'm going in the wrong direction.

What's interesting (to me, anyway) is that my timing doesn't line up with yours - I was scraping b-ref on the date you opened this issue without problem, yet today is the first time I encountered this error.

TK2575 avatar Oct 05 '22 16:10 TK2575

No problem with bref_team_results("MIN", 2022) on my end, @darrenpage15. Have you tried updating to the latest version or reinstalling altogether?

rdelrossi avatar Oct 21 '22 19:10 rdelrossi

On most recent dev release, we've added a 5 second rest for all calls to baseball-reference functions to comply with their scraping guidelines announced recently. While I believe all 403 and 429 issues should resolve themselves within 24 hours or so according to their new policy. As a result of complying, these 403/429 issues will stop happening, even if the time to resolve the query will take ~5x amount of time as it used to.

saiemgilani avatar Nov 09 '22 09:11 saiemgilani