Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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