Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wmcraver
Last active November 18, 2016 19:39
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 wmcraver/8a44b49c9924ef83e4710fba1e566e7a to your computer and use it in GitHub Desktop.
Save wmcraver/8a44b49c9924ef83e4710fba1e566e7a to your computer and use it in GitHub Desktop.
urlStatusChecker = function(file,urlcol) {
library(httr)
dat = read.csv(file, stringsAsFactors = F)
for (i in 1:nrow(dat)) {
dat = dat[dat[urlcol] != "",]
dat = dat = dat[!is.na(dat[urlcol]),]
a = GET(dat[i,urlcol])
dat$URL[i] = a$url
dat$StatusCode[i] = status_code(a)
print(paste("URL: ", i, " || ", dat$URL[i], " || Status: ",dat$StatusCode[i], sep = ""))
}
write.csv(dat, file = paste(file, "-checked.csv", sep = ""))
}
urlStatusChecker("AirportList.csv", 7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment