Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jlopezper
Created February 9, 2019 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlopezper/4e9509fce25e7d481cd648ddc49b7297 to your computer and use it in GitHub Desktop.
Save jlopezper/4e9509fce25e7d481cd648ddc49b7297 to your computer and use it in GitHub Desktop.
library(httr)
library(dplyr)
library(magrittr)
library(purrr)
get_holidays <- function(country_code, year) {
# Build URL
url <- parse_url("http://date.nager.at")
url$path <- paste0("api/v1/get/", country_code, "/", year)
base_url <- build_url(url)
# Get content from the site
content_json <- content(GET(base_url))
# Extract only relevant fields
df <- map_df(content_json, extract, c("countryCode", "name", "date"))
df
}
years <- c("2016", "2017", "2018", "2019")
map_df(years, function(x) get_holidays("AT", x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment