Previous chapter
Case StudiesA dynamic price comparison workbook from willhaben.at

## A dynamic price comparison workbook from willhaben.at

In this exercise we want to create a dynamic price comparison workbook based on current data from the popular Austrian website [willhaben.at]](https://www.willhaben.at).

1. Use the code in the next section to extract all relevant data to a data.frame
2. Create a new Excel workbook including a 2.1. Sheet with a nicely formatted table. Add a column including the price/square meter. 2.2. Sheet with a price histogram/density plot.
3. Optional: Make sure that the sheet gets updated incrementaly if run multiple times.

## Extract first ten pages from result set in willhaben

``````library(rvest)
library(dplyr)

pages <- 1:10
html_select <- '//*[contains(concat( " ", @class, " " ), concat( " ", "isRealestate", " " ))]'

path_result = "//section[@class='content-section isRealestate']"
path_size <- paste0(path_result, "/div[@class='info']/span[@class='desc-left']")
path_rooms <- paste0(path_result, "/div[@class='info']/span[@class='wh-pipe']")

path_price <- paste0(path_result, "//div[@class='info']")

path_price <- paste0(path_result, "//*[@id='resultlist']/article[1]/section[3]/div[2]/span[2]")
path_bottom <- paste0(path_result, "/div[@class='bottom']")

items <- list()
for (l in links) {
link <- nodes_page %>% html_nodes(xpath = path_link) %>% html_attr('href')