Skip to content

Instantly share code, notes, and snippets.

@rossmounce
Created February 7, 2017 21:55
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 rossmounce/1faf254d149a57ceb958c6dc4d026847 to your computer and use it in GitHub Desktop.
Save rossmounce/1faf254d149a57ceb958c6dc4d026847 to your computer and use it in GitHub Desktop.
#!/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