, lapply .product_price :
r.precio.antes <- page_source %>% html_nodes(".product_price") %>%
lapply(. %>% html_nodes(".normal_encontrado") %>% html_text() %>%
ifelse(identical(., character(0)), NA, .)) %>% unlist
NA, .normal_encontrado .
r.precio.antes
# [1] "\n S/. 2,799.00\n "
# [2] NA
length(r.precio.antes) # 2
, , .product_price:
product_nodes <- page_source %>% html_nodes(".product_price")
lapply :
r.precio.antes <- lapply(product_nodes, function(pn) {
pn %>% html_nodes(".normal_encontrado") %>% html_text()
})
r.precio.antes <- unlist(r.precio.antes)
magrittr lapply, ., , .
, , character(0), NA, . ifelse(identical(., character(0)), NA, .)) , .
source
share