Skip to content

Commit

Permalink
reduced download_t100 download time
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipeamTeixeira committed Sep 12, 2024
1 parent 1bfdffd commit fb902f7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions R/download_t100.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ download_t100 <- function(y = NULL, type = NULL){
followlocation = TRUE, autoreferer = TRUE, curl = curl)

message("Connecting to T100")
html <- getURL('https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIL&QO_fu146_anzr=Nv4%20Pn44vr45', curl = curl)
temp <- GET('https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIL&QO_fu146_anzr=Nv4%20Pn44vr45', curl = curl)
#html <- getURL('https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIL&QO_fu146_anzr=Nv4%20Pn44vr45', curl = curl)
html <- GET('https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIL&QO_fu146_anzr=Nv4%20Pn44vr45', curl = curl)
message("Done")

viewstate <- as.character(sub('.*id="__VIEWSTATE" value="([0-9a-zA-Z+/=]*).*', '\\1', html))
Expand Down Expand Up @@ -94,13 +94,12 @@ download_t100 <- function(y = NULL, type = NULL){
followlocation = TRUE, autoreferer = TRUE, curl = curl)

message("Connecting to T100")
html <- getURL("https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIM&QO_fu146_anzr=Nv4%25Pn44vr45", curl = curl)
temp <- GET("https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIM&QO_fu146_anzr=Nv4%25Pn44vr45", curl = curl)
#html <- getURL("https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIM&QO_fu146_anzr=Nv4%25Pn44vr45", curl = curl)
html <- GET("https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIM&QO_fu146_anzr=Nv4%25Pn44vr45", curl = curl)
message("Done")

viewstate <- as.character(sub('.*id="__VIEWSTATE" value="([0-9a-zA-Z+/=]*).*', '\\1', html))
viewstategenerator <- as.character(sub('.*id="__VIEWSTATEGENERATOR" value="([0-9a-zA-Z+/=]*).*', '\\1', html))

eventvalidation <- as.character(sub('.*id="__EVENTVALIDATION" value="([0-9a-zA-Z+/=]*).*', '\\1', html))

message("Downloading file")
Expand Down

0 comments on commit fb902f7

Please sign in to comment.