#' List all members of a category
#'
#' @param x Category's name or id
#' @param domain The domain where the wiki is located
#' @param namespace The namespace of contributions
#'
#' @return A data-frame
#' @export
#'
#' @importFrom magrittr %>% %<>%
#'
cat_page <- function(x, domain = "fr", namespace = "0") {
result <- matrix(ncol = 5)
query = list(
action = "query",
list = "categorymembers",
cmlimit = "max",
namespace = namespace,
cmprop = "ids|title|type|timestamp",
redirects = "")
if(is.numeric(x)) {
query["cmpageid"] <- x
} else {
query["cmtitle"] <- x
}
repeat {
exec <- exec_query(query, domain)
tmp <- unlist(exec$query$categorymembers) %>%
matrix(ncol = 5, byrow = T)
result <- rbind(result, tmp)
if("continue" %in% names(exec)) {
query["cmcontinue"] <- exec$continue$cmcontinue
print("test")
} else {
break
}
}
result <- as.data.frame(result[-1, ], stringsAsFactors = FALSE)
# Mise en forme
result[, 1] %<>% as.numeric()
result[, 2] %<>% as.numeric()
result[, 4] %<>% as.factor()
result[, 5] %<>% strptime("%Y-%m-%dT%H:%M:%SZ") %>%
as.POSIXct()
names(result) <- c("pageid", "ns", "title", "type", "inclusion_date")
result
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.