install.packages("rcoreoa")
install.packages("RCurl")
library(rcoreoa)
library(RCurl)
setwd("D:/EECA/INICIACAO_CIENTIFICA/")
CORE_KEY= "7rIUuYomD51JXjEKNypFnGhZWV68zgdB" # Recebida por email...
QUERY = data.frame("all_of_the_words" = "warming global",
"find_those_words" = "b",
"language" = "en",
"year_from" = "2017",
"year_to" = "2019")
RES = data.frame(ID=character(),
Author_1st=as.character(),
Title=as.character(),
Year=as.character(),
Description=as.character(),
Download_link=as.character())
last = round(core_advanced_search(query = QUERY, key = CORE_KEY)$totalHits/100)
for (pp in 1:2){
res = core_advanced_search(query = QUERY,
key = CORE_KEY,
page = pp,
limit = 100)
RES = rbind(RES,
data.frame(ID = res$data$_source
$id,
Author_1st = unlist(lapply(res$data$_source
$authors, function(x) x[1])),
Title = res$data$_source
$title,
Year = res$data$_source
$year,
Description = unlist(res$data$_source
$description),
Download_link = res$data$_source
$downloadUrl)
)
}
who = which(RES$Download_link != "" & RES$Description != "")
RES = RES[who,]
write.csv2(RES,"warming.csv", row.names = FALSE)
RES = read.csv2("warming.csv")
for (i in 1:nrow(RES)){
my_filename =
my_destfile = paste("D:/EECA/INICIACAO_CIENTIFICA/ARTIGOS/V2/",
RES$Author_1st[i],
" (",RES$Year[i],").pdf", sep="")
my_url = as.character(RES$Download_link[i])
if (url.exists(my_url)){
download.file(url = my_url,
destfile = my_destfile,
mode = "wb")
}
}