Skip to content

Commit

Permalink
query FAA data via GET (#21)
Browse files Browse the repository at this point in the history
Now passing along a user agent.
  • Loading branch information
simonpcouch committed Sep 7, 2023
1 parent 12102ea commit 0954140
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ get_planes_data <- function(year, dir, flights_data) {

# put together the url to query the planes data at
planes_src <- paste0(
"http://registry.faa.gov/database/yearly/ReleasableAircraft.",
"https://registry.faa.gov/database/yearly/ReleasableAircraft.",
year,
".zip"
)
Expand All @@ -466,8 +466,13 @@ get_planes_data <- function(year, dir, flights_data) {

# download the planes data
planes_tmp <- tempfile(fileext = ".zip")
download_file_wrapper(planes_src, planes_tmp, quiet = TRUE)

planes_response <-
httr::GET(
planes_src,
httr::user_agent("anyflights"),
httr::write_disk(planes_tmp, overwrite = TRUE)
)

# ...and unzip it!
utils::unzip(planes_tmp, exdir = planes_lcl, junkpaths = TRUE)

Expand Down Expand Up @@ -515,10 +520,12 @@ process_planes_ref <- function(planes_lcl) {
# download the planes acftref data
planes_tmp <- tempfile(fileext = ".zip")

download_file_wrapper(
"http://registry.faa.gov/database/yearly/ReleasableAircraft.2019.zip",
planes_tmp,
quiet = TRUE)
planes_response <-
httr::GET(
"https://registry.faa.gov/database/yearly/ReleasableAircraft.2019.zip",
httr::user_agent("anyflights"),
httr::write_disk(planes_tmp, overwrite = TRUE)
)

# ...and unzip it!
utils::unzip(planes_tmp, exdir = planes_lcl, junkpaths = TRUE)
Expand Down

0 comments on commit 0954140

Please sign in to comment.