Last active
September 28, 2016 22:41
-
-
Save wmcraver/652bf4132680ce6a35e914ec3b7a13d3 to your computer and use it in GitHub Desktop.
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(httr) | |
library(stringr) | |
dat = read.csv("fileWithURLs.csv", stringsAsFactors = F) | |
---------------- for loop to get results ---------------- | |
for (i in 1:nrow(dat)) { | |
a = GET(dat$Current.Forward[i]) | |
dat$URL[i] = a$url | |
dat$StatusCode[i] = status_code(a) | |
} | |
---------------- wrote a function to do this ---------------- | |
urlGetter = function(URL) { | |
a = GET(URL) | |
print(a$url) | |
print(status_code(a)) | |
data.frame("STATUS" = status_code(a),"URL" = a$url) | |
} | |
x = sapply(dat$URLlist,urlGetter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment