Created
February 7, 2017 21:55
-
-
Save rossmounce/1faf254d149a57ceb958c6dc4d026847 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env Rscript | |
#install.packages("dplyr") | |
#install.packages("httr") | |
library(dplyr, warn.conflicts=FALSE) | |
library(httr) | |
uniquedois <- read.csv(file="wellcomeDOIs.txt",header=F,stringsAsFactors = F) | |
uniquedois <- as.data.frame(uniquedois) | |
vec <- vector("list",length(uniquedois$V1)) | |
for (doi in (seq(1,length(uniquedois$V1)))){ | |
vec[doi] <- try(http_status(GET(uniquedois$V1[doi], timeout(6), user_agent("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0; Trident/5.0)")))$message) | |
} | |
table <- data.frame(matrix(unlist(vec)),uniquedois) | |
table | |
names(table)[1] <- "HTTP.Status" | |
names(table)[2] <- "DOI" | |
datestamp <- paste(format(Sys.time(), "%Y-%m-%d-%I-%p"), "csv", sep = ".") | |
write.csv(table,file=datestamp,row.names = F) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment