This was interesting because I learned that constructing a tibble/data.frame with a variable that you assign only a character(0) to, means the whole row will not be created, so thats why I paste and empty string.
library(rvest)
library(dplyr)
bbs <- html("https://www.bizbuysell.com/california-businesses-for-sale/?q=aXI9MSZzcGlkPTEmdz1x ")
bbs_listingresults<- bbs %>% html_nodes(".listingResult")
library(purrr)
map_dfr(bbs_listingresults,
~ tibble(price=paste0("",html_text(html_nodes(.,".price"))),
info=paste0("",html_text(html_nodes(.,".info"))),
hiddenphone=paste0("",html_text(html_nodes(.,".hidden-phone")),collapse = ";"))
) -> bbs_listingresults_df
bbs_listingresults_df
# A tibble: 50 x 3
price info hiddenphone
<chr> <chr> <chr>
1 "$250,000" Los Angeles, CA Cash Flow: $60,000;Contact Seller
2 "$324,000" Sacramento, CA Cash Flow: $108,000;Contact Seller
3 "$1,650,000" Modesto, CA Cash Flow: $519,388;Contact Seller
4 "$780,000" Los Angeles County, CA Cash Flow: $192,165;Contact Seller
5 "$2,000,000" Los Angeles County, CA Cash Flow: $436,216;Contact Seller
6 "$249,000" Pasadena, CA Cash Flow: $135,000;Contact Seller
7 "$730,000" Los Angeles County, CA Cash Flow: $368,381;Contact Seller
8 "$260,000" Orange, CA Contact Seller
9 "$42,768" San Diego, CA Cash Flow: $41,805;Contact Seller
10 "" Orange County, CA Cash Flow: $1,538,900;Contact Seller
# ... with 40 more rows