Created
August 11, 2017 20:25
-
-
Save cdmh/4906f4144858a45907116b49d92c172b to your computer and use it in GitHub Desktop.
convert parkrun results web page to CSV
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
library(tidyverse) | |
library(htmltab) | |
# right-click and save HTML | |
# this is the results page, e.g. http://www.parkrun.org.uk/henleyonthames/results/weeklyresults/?runSeqNumber=2 | |
doc <- read_file("results _ henleyonthames parkrun_2.html") | |
df <- as_tibble(htmltab(doc=doc, which="//table[@id='results']")) | |
colnames(df) <- c("pos", "name", "time", "age_cat", "age_grade", "gender", "gender_pos", "note", "total_runs") | |
df$pos <- as.numeric(df$pos) | |
df$total_runs <- as.numeric(df$total_runs) | |
df$gender_pos <- as.numeric(df$gender_pos) | |
d1 <- as_tibble(df) | |
write.csv(d1, file = "results _ henleyonthames parkrun_2.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment