I'm scrapping with rvest and I have trouble with filling the empty values with NA.
The first section extracts the nodes, for this example I get 65 results. But on the "trebol" values I only get 11 and i want to fill the rest of the values with NA to complete de dataframe with the corresponding values.
I hope it's clear, I'm pretty new here..
library(rvest)
library(stringr)
library(tidyverse)
library(dplyr)
hoteles_verdes <- read_html('Boston_Mayo 2022.html') # file name
hoteles_verdes %>%
html_nodes("div.a826ba81c4") %>%
html_text()
trebol <- hoteles_verdes %>%
html_elements("span.a51f4b5adb")%>%
html_text()
hotelesDF <- tibble(nombres, tarifa, trebol, distancia, links) #here I create the data frame with the rest of the thing i extracted that have 65 results