Skip to content

Instantly share code, notes, and snippets.

@ColinFay
Created April 7, 2022 07:19
Show Gist options
  • Save ColinFay/eecb51e741973acaa206ca9a8d6530f4 to your computer and use it in GitHub Desktop.
Save ColinFay/eecb51e741973acaa206ca9a8d6530f4 to your computer and use it in GitHub Desktop.
Get all Paris Marathon Data
r <- httr::GET("https://resultscui.active.com/api/results/events/SchneiderElectricMarathondeParis2022/participants?groupId=943954&routeId=170393&offset=34357&limit=100") |>
httr::content() |>
rawToChar() |>
jsonlite::fromJSON()
base <- 0
r <- list()
continue <- TRUE
offset <- 0
r <- httr::GET(
sprintf(
"https://resultscui.active.com/api/results/events/SchneiderElectricMarathondeParis2022/participants?groupId=943954&routeId=170393&offset=%s&limit=100", offset
)
)|> x
httr::content() |>
rawToChar() |>
jsonlite::fromJSON()
offset <- offset + 100
while (continue) {
Sys.sleep(1)
cli::cat_rule(
offset
)
res <- httr::GET(
sprintf("https://resultscui.active.com/api/results/events/SchneiderElectricMarathondeParis2022/participants?groupId=943954&routeId=170393&offset=%s&limit=100", offset)
) |>
httr::content() |>
rawToChar() |>
jsonlite::fromJSON()
if (length(r$items) == 0) {
continue <- FALSE
} else {
r$items <- dplyr::bind_rows(r$items, res$items)
offset <- offset + 100
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment