R/get_race_page.R

#' Grab the set of races
#'
#' There is a webpage that has a list of all the races
#' @export

get_race_page <- function(){
  race_URL <- "http://www.scottishhillracing.co.uk/ResultsSummary.aspx"
  webPage <- as.character(read_html(race_URL))

  per_site <- strsplit(webPage,
                       "RaceDetails.aspx?RaceID",
                       fixed = TRUE)[[1]][-1]
  actual_sites <- per_site[seq(2, length(per_site), by = 2)]

  site_id <- substr(actual_sites, 2,8)
  site_name <- str_extract(actual_sites, ">[a-zA-Z0-9 ]*<")

  data.frame(id = site_id, name = site_name)
}
gdking01/ScottishHillRacing documentation built on May 17, 2019, 12:12 a.m.