#' Scrape Google Play Store search results
#'
#' @param search_term getData will search the Google Play Store for apps using this search term
#' @import rvest xml2
#' @importFrom purrr map_df
#' @export
#' @return A data frame of the data scaped from each app page for each app on the search results page.
#' @examples
#' getData("steganography")
getData <- function(search_term){
# get url for search_term
search_url <- paste0("https://play.google.com/store/search?q=", search_term,"&c=apps")
# get html of search_url page
html <- read_html(search_url)
# get links of all apps listed on search_url
links <- html %>%
rvest::html_nodes('body') %>%
xml2::xml_find_all("//a[contains(@class, 'poRVub')]") %>%
html_attr("href")
# convert to list
links <- as.list(links)
# add "https://play.google.com" to begining of each link
links <- lapply(links, function (x) (paste0("https://play.google.com", x)))
# get the data for each app on the search_url page
details <- lapply(links, function (x)(getData_SingleApp(x)))
# Convert from list of lists to a data frame
data <- map_df(details, function (x) as.data.frame(x, stringsAsFactors=FALSE))
return(data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.