| bref_read_html | R Documentation |
Baseball Reference rate-limits (HTTP 429) scrapers that make rapid
sequential requests. xml2::read_html() has no built-in retry, so a
429 surfaces as a generic error and the caller's tryCatch swallows it
into a misleading "Invalid arguments or no data available" message (#344).
This helper uses httr2::req_retry() to retry 429 / 503 responses
with exponential backoff (up to 3 tries), then passes the response
body to xml2::read_html(). A 5-second courtesy delay mirrors the
existing NCAA scraper convention.
bref_read_html(url, max_tries = 3L)
url |
A Baseball Reference URL. |
max_tries |
Integer. Maximum number of attempts (default 3). |
An XML document as returned by xml2::read_html().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.