Last active
November 14, 2017 16:13
-
-
Save padpadpadpad/bbdd40d6f92d5199d38fd86da94b0d8a to your computer and use it in GitHub Desktop.
code to get Guardian quick crossword
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
# load packages | |
library(dplyr) | |
library(tidyr) | |
# get today's date and base url in the dataframe | |
dat <- data.frame(date = as.character(Sys.Date()), | |
url = 'https://crosswords-static.guim.co.uk/gdn.quick.pdf') | |
# replace '-' with '' | |
dat <- mutate(dat, date = gsub('-', '', date)) | |
# split the address up on the dots | |
dat <- separate(dat, url, into = paste('C', 1:6, sep = ''), sep = '\\.') | |
# create new url from columns needed for today's crossword | |
fullURL <- unite(dat, fullURL, c(C1, C2, C3, C4, C5, date, C6), sep = '.') %>% | |
pull(., fullURL) | |
fullURL | |
#open it in browser | |
browseURL(fullURL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment