Created
June 7, 2018 07:44
-
-
Save psobczyk/53361146aa66243f6adb7a2a6be307b4 to your computer and use it in GitHub Desktop.
scraping data from timeanddate.com
This file contains 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(rvest) | |
library(dplyr) | |
main_page <- read_html('https://www.timeanddate.com/holidays/') | |
all_countries <- main_page %>% | |
html_nodes(xpath = '//div[@class="row"]//li//a') %>% | |
html_attr(name = 'href') | |
holidays <- NULL | |
pb <- progress_estimated(length(all_countries)) | |
for(country in all_countries){ | |
url <- sprintf('https://www.timeanddate.com/%s', country) | |
tmp <- read_html(url) %>% | |
html_table() %>% .[[1]] %>% | |
mutate(country=country) | |
holidays[[country]] <- tmp | |
pb$tick()$print() | |
} | |
holidays <- do.call(bind_rows, holidays) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment