Created
July 25, 2015 10:40
-
-
Save timcdlucas/e98ab95e9e7cd810899b to your computer and use it in GitHub Desktop.
Scrape the number of citations on pubmed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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