#' Build url for RSS feed for Google News per search
#'
#' @name qnews_build_rss
#' @param x Search term
#' @return A character string
#'
#' @export
#' @rdname qnews_build_rss
#'
qnews_build_rss <- function(x = NULL) {
clang_suffix <- 'hl=en-US&gl=US&ceid=US:en&q='
base <- "https://news.google.com/news/rss/search?"
tops <- "https://news.google.com/news/rss/?ned=us&hl=en&gl=us"
if(is.null(x)) rss <- tops else {
x <- strsplit(x, ' AND ')[[1]]
y <- unlist(lapply(x, function(q) gsub(' ', '%20', q)))
y1 <- lapply(y, function(q) gsub('(^.*$)', '%22\\1%22', q))
search1 <- paste(y1, collapse = "%20AND%20")
rss <- paste0(base, clang_suffix, search1)
}
return(rss)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.