Created
April 7, 2022 07:19
-
-
Save ColinFay/eecb51e741973acaa206ca9a8d6530f4 to your computer and use it in GitHub Desktop.
Get all Paris Marathon Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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