Skip to content

Instantly share code, notes, and snippets.

@timcdlucas
Created July 25, 2015 10:40
Show Gist options
  • Save timcdlucas/e98ab95e9e7cd810899b to your computer and use it in GitHub Desktop.
Save timcdlucas/e98ab95e9e7cd810899b to your computer and use it in GitHub Desktop.
Scrape the number of citations on pubmed
scrapePub <- function(sp){
Sys.sleep(2)
spString <- tolower(gsub(' ', '+', sp))
url <- paste0('http://www.ncbi.nlm.nih.gov/pubmed/?term=%22', spString, '%22')
page <- html(url)
try({
refs <- page %>%
html_node('.result_count') %>%
html_text() %>%
strsplit(' ') %>%
.[[1]] %>%
.[length(.)] %>%
as.numeric()
})
return(refs)
}
scrapePub('Myotis myotis')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment