Created
July 19, 2016 11:44
-
-
Save havran/21a5b5f27bfdfcc2ef65ba2fcac5fcf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Spustit cez []->Source | |
# | |
library(curl) | |
library(jsonlite) | |
# Zistime si meno adresara v ktorom sa nachadza subor so scriptom | |
sourceDir <- getSrcDirectory(function(dummy) {dummy}) | |
# Vlozime script s funciami pre geocoding. | |
source(paste(sourceDir, '/', 'geocoding.R', sep = '')) | |
# Ziskame data s pobockami CSOB. | |
pobocky_data <- fromJSON("https://www.csob.sk/delegate/mapsSearch?REQUEST_TYPE=0&gps_lat=48.7&gps_lon=19.600000000000023&pocet=501&offset=0&typ=pobocky&financni_centra=1&bankomaty=0&bcmType=1&pip=&sui=&eurokonto=&hypotecni_uver=&nejnizsi_uroven_posty=R1&meritko=7&ne_lat=50.305105883986506&ne_lon=23.280419921875023&sw_lat=47.04202810999916&sw_lon=15.919580078125023&opened_weekend=false&return_all=0&filterByServices=") | |
# Ziskame data s bankomatmi CSOB. | |
bankomaty_data <- fromJSON("https://www.csob.sk/delegate/mapsSearch?REQUEST_TYPE=0&gps_lat=48.6129128454839&gps_lon=19.643945312500026&pocet=501&offset=0&typ=pobocky&financni_centra=0&bankomaty=1&bcmType=5&pip=&sui=&eurokonto=&hypotecni_uver=&nejnizsi_uroven_posty=R1&meritko=7&ne_lat=50.22082781486276&ne_lon=23.324365234375023&sw_lat=46.95211131623264&sw_lon=15.963525390625023&opened_weekend=false&return_all=0&filterByServices=") | |
# Vytvorime si prazdny list pre pobocky. | |
pobocky <- list() | |
# V cykle vyberieme vsetky poboky z JSONu. (Cez names() ziskame vsetky kluce pobociek). | |
for (key in names(pobocky_data$objekty)) { | |
# Podla indexu vyberieme data konkretnej pobocky a cez rbind ich pridame do listu pobocky. | |
pobocky <- rbind(pobocky, pobocky_data$objekty[[key]]) | |
} | |
# Skonvertujeme list do data frame. | |
pobocky <- as.data.frame(pobocky) | |
# rovnaky postup ako pre pobocky zopakujeme pre bankomaty. | |
bankomaty <- list() | |
for (key in names(bankomaty_data$objekty)) { | |
bankomaty <- rbind(bankomaty, bankomaty_data$objekty[[key]]) | |
} | |
bankomaty <- as.data.frame(bankomaty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment