R/hd_product_specs.R

#' Scrape and format product specifications from a product's web page
#' @param x A string, a connection, or a raw vector.
#' @return Returns a list of tibbles of product characteristics and specs
#' @export
#' @examples
#' \dontrun{
#' rx142 <- "http://www.homedepot.com/p/Cerrowire-250-ft-14-2-White-NM-B-Wire-147-1472G/202304609"
#' hd_product_specs(rx142)
#' }
hd_product_specs <- function(x) {
  xml2::read_html(x) %>%
    rvest::html_nodes("table") %>%
    rvest::html_table() %>%
    setNames(nm = c("dimensions", "details", "warranty"))
}
burtonlueth/webPrices documentation built on May 13, 2019, 8:47 a.m.