R/rt_get_comments.R

Defines functions rt_get_comments

Documented in rt_get_comments

#' Extract comments from robots.txt
#' @param txt content of the robots.txt file
#' @keywords internal
rt_get_comments <- function(txt){
  txt      <- unlist(stringr::str_split(txt, "\n"))
  clines   <- grep("#", txt)
  ccontent <- stringr::str_extract(txt[clines], "#.*")
  data.frame(line=clines, comment=ccontent, stringsAsFactors = FALSE)
}
ropensci/robotstxt documentation built on Sept. 3, 2024, 2:32 a.m.