library(rvest)
scrape_standings <- function(year = 2025) {
url <- paste0("https://www.basketball-reference.com/leagues/NBA_", year, ".html")
x <- url |>
read_html() |>
html_table()
x[1:2] |>
map(janitor::clean_names) |>
map(rename_with, ~str_remove(.x, "eastern_|western_"), contains("conference")) |>
list_rbind() |>
mutate(
p_ratio = ps_g / pa_g,
wpct = w_l_percent,
logWratio = log(w / l),
logPratio = log(ps_g / pa_g)
)
}














