#' @title Get the list of countries
#' @description Collect data on countries which will be necessary for location based filters
#' @param print_steps Print out proress
#' @return data.frame of countries
#' @export
#' @examples
#' get_countries()
#' @importFrom magrittr "%>%"
get_countries <- function(print_steps = F){
base_url <- "https://www.sahibinden.com/ajax/location/loadCountriesAsMap"
response <- httr::GET(
url = base_url,
if(print_steps) httr::verbose() else NULL
)
if(httr::status_code(response) == 200) {
if(print_steps) cat("Countries are retrieved with success\n")
content <- httr::content(response)
countries <- lapply(unlist(content$data, recursive = F), flatten) %>%
dplyr::bind_rows() %>%
dplyr::as.tbl()
return(countries)
} else {
if(print_steps) cat("Data not found!\n")
return(NULL)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.