Home > Net >  Web scraping data from a Chart or Graph in R
Web scraping data from a Chart or Graph in R

Time:12-01

Good Morning,

I am hoping someone can help. The task is straight forward but seems a little difficult to execute.

On this website: https://reiwa.com.au/rent/

There is a chart labelled: Property trends

I am trying to extract the two time-series form this chart.

I have used rvest etc but I have had no luck at all. I am really hoping someone has the skills to solve this one because it has me lost.

Thank you all in advance.

CodePudding user response:

A little inspection with Chrome devtools led me to this:

res <- httr::GET("https://reiwa.com.au/api/insights/trends/Residential")
json <- jsonlite::fromJSON(httr::content(res, "text"))

head(json$Result$SaleTrends)
#>   CalendarYear CalendarMonth     DateLabel MedianPrice DisplayPrice ChartOrder
#> 1         2020      December December 2020      490000        $490k         12
#> 2         2021       January  January 2021      495000        $495k         13
#> 3         2021      February February 2021      500000        $500k         14
#> 4         2021         March    March 2021      505000        $505k         15
#> 5         2021         April    April 2021      510000        $510k         16
#> 6         2021           May      May 2021      515000        $515k         17

head(json$Result$LeaseTrends)
#>   CalendarYear CalendarMonth     DateLabel MedianPrice DisplayPrice ChartOrder
#> 1         2020      December December 2020         410       $410pw         12
#> 2         2021       January  January 2021         420       $420pw         13
#> 3         2021      February February 2021         420       $420pw         14
#> 4         2021         March    March 2021         430       $430pw         15
#> 5         2021         April    April 2021         440       $440pw         16
#> 6         2021           May      May 2021         450       $450pw         17
  • Related