Hi All!
I'm trying to create a webscraping tool for propertyfinder, so I have this code chunk below,
but it keeps giving me an error saying "unexpected symbol" on the for loop part. I just don't know where the problem is.
Thanks a lot for the help guys!! Appreciated
get_age <- function(property_link) {
property_page = read_html(property_link)
listing_age = property_page %>% html_node(".property-page__legal-list+ .property-page__legal-list .property-page__legal-list-item--value") %>%
html_text()
return(listing_age)
}
newprop <- data.frame()
for (property_pages in 1:25) {
link = paste("https://www.propertyfinder.ae/en/search?c=1&cs=off_plan&l=6&ob=mr&page="
property_pages)
page <- read_html(link)
Property <- page %>% html_nodes(".card__location-text") %>% html_text()
Price <- page %>% html_nodes (".card__price-value") %>% html_text ()
Property_Type <-page %>% html_nodes(".card__property-amenity--property-type") %>% html_text()
Area <- page %>% html_nodes(".card__property-amenity--area") %>% html_text()
Description <- page %>% html_nodes (".card__property-title-payment-plan span , .card__title-link") %>% html_text()
Bedroom <- page %>% html_nodes (".card__property-amenity--bedrooms") %>% html_text()
Bathroom <- page %>% html_nodes(".card__property-amenity--bathrooms") %>% html_text()
list_age <- sapply(url, FUN = get_age, USE.NAMES = FALSE)
newprop <- rbind(data.framedata.frame(Property, Property_Type, Price, Area,
Bedroom, Bathroom,list_age, Description, url, stringASFactors = FALSE))
print(paste("Page:", page_result))
}