I'm an absolute R beginner and I've been trying to scrape shoe prices from this Sprinter Sports page, with the ultimate goal of having a dataset that will automatically load, on a daily basis, (i) original and (ii) discounted prices for shoes I'm interested in.
The problem is that, of the 24 shoes currently for sale, only 16 have both an "original" and "discounted" price. The remaining 8 don't have a "discounted" price as they are not being sold at a discount. Since the "original" column has 24 observations, and the "discounted" column only has 16, I can't join these together in a dataset.
How can I load shoes without a discount such that their "discounted" column is set to NA? My code is below. Thanks!
date_today = substring(gsub("-", "", Sys.Date()),3)
page_sp_merrel <- read_html("https://www.sprintersports.com/pt/sapatilhas-merrell-homem?page=1&per_page=50")
price_old_sp_merrel <- page_sp_merrel %>%
html_nodes(".product-card__info-price-old") %>%
html_text()
price_new_sp_merrel <- page_sp_merrel %>%
html_nodes(".product-card__info-price-actual") %>%
html_text()
product_name_sp_merrel <- page_sp_merrel %>%
html_nodes(".col-md-3 .product-card__info-name") %>%
html_text()
sp_merrel_df <- tibble(
price_old = price_old_sp_merrel,
price_new = price_new_sp_merrel,
product_name = product_name_sp_merrel,
date = date_today
)