R/exec_query.R

#' Execute a query to the MediaWiki API
#' 
#' @param query A list giving query information
#' @param domain The domain where the wiki is located.
#'
#' @importFrom httr content GET
#' @importFrom magrittr %>%
#' 
#' @export

exec_query <- function(query, domain = "fr") {
  
  query["format"] <- "json"
  
  tryCatch({paste("https://", domain, ".wikipedia.org/w/api.php", sep = "") %>%
      GET(query = query) %>%
      content("parsed")}, error = function(e) NULL)
  
}
leojoubert/WikiSocio documentation built on May 21, 2019, 5:08 a.m.