Skip to content

Instantly share code, notes, and snippets.

@PatrickStotz
Created March 25, 2020 10:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickStotz/863fa0e0863ed5728cd01aaea9660101 to your computer and use it in GitHub Desktop.
Save PatrickStotz/863fa0e0863ed5728cd01aaea9660101 to your computer and use it in GitHub Desktop.
Scraping TomTom Congestion data
needs(tidyverse, jsonlite, lubridate)
cities = c("frankfurt-am-main", "cologne", "berlin", "hamburg", "munich")
for (city in cities){
url = paste0("https://api.midway.tomtom.com/ranking/live/DEU%2FCircle%2F", city)
data = fromJSON(url)
table = data$data %>%
select(TrafficIndexLive, TrafficIndexHistoric, UpdateTime) %>%
mutate(time = as_datetime(UpdateTime / 1000)) %>%
mutate(city = city)
if (!exists("collection")){ collection = table }
else { collection = collection %>% bind_rows(table)}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment