Skip to content

Instantly share code, notes, and snippets.

@louisahsmith
Created January 17, 2020 18:03
Show Gist options
  • Save louisahsmith/4bc2a97f7847ee4286d97ab6502f98d3 to your computer and use it in GitHub Desktop.
Save louisahsmith/4bc2a97f7847ee4286d97ab6502f98d3 to your computer and use it in GitHub Desktop.
create a text file with all the SER abstracts assigned to you
library(rvest)
username <- "louisa_h_smith"
.password <- rstudioapi::askForPassword("SER password")
save_path <- "~/Desktop"
get_abstract_text <- function(i, review_homepage, titles) {
abstract <- jump_to(review_homepage, links[i])
text <- html_nodes(abstract, "article") %>%
html_children() %>%
html_children() %>%
html_children() %>%
html_text()
content <- sub(".*\\_+ *(.*?) *Review Form \\- Score \\+ Notes.*", "\\1", text[2])
paste(titles[i], content, collapse = "\n\n")
}
url <- "https://epiresearch.org/membership-required/?redirect_to=review-homepage"
session <- html_session(url)
login_form <- html_form(session)[[1]]
filled_form <- set_values(login_form, log = username, pwd = .password)
submit_form(session, filled_form)
review_homepage <- jump_to(session, "https://epiresearch.org/review-homepage/")
links <- html_nodes(review_homepage, "a") %>%
html_attr("href") %>%
grep("\\?review\\=", ., value = TRUE)
titles <- html_nodes(review_homepage, "h5") %>%
html_text()
res <- vapply(
seq_along(links),
get_abstract_text,
character(1),
review_homepage = review_homepage,
titles = titles
)
sink(file.path(save_path, "reviews.txt"))
cat(res)
sink()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment