R/get.functions.R

Defines functions get.article.title get.article.abstracts get.article.authors get.article.journal get.article.date get_using_get.article.types

#scrape functions
# Get all titles
get.article.title <- function(article) {
  article %>%
    xml_nodes(xpath =  './/ArticleTitle') %>%
    xml_text() %>%
    return()
}



# Get abstracts
get.article.abstracts <- function(article){
  article %>%
    xml_nodes(xpath =  './/Abstract') %>%
    xml_text() %>%
    return()
}

# Get Authors
# list of tibbles
get.article.authors <- function(article){
  article %>%
  xml_nodes(xpath =  './/Article')  %>%
  map( .f = get.authors)%>%
    return()
  }


#Get journal
get.article.journal<-  function(article){
  article %>%
  xml_nodes(xpath =  './/Journal/Title') %>%
  xml_text() %>%
  return()
}

#Get pubdate
get.article.date <- function(article){
  article %>%
  xml_nodes(xpath =  './/ArticleDate') %>%
    xml_text()  %>%
    ymd() %>%
    return()
}

#Get article types
get_using_get.article.types <- function(article){
  article %>%
    xml_nodes(xpath =  './/Article') %>%
    map(.f = get.article.types) %>%
    unlist() %>%
    return()
}
ShawnBrad/SearchPubmed documentation built on Jan. 19, 2020, 5:19 p.m.