You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
979 B

3 years ago
  1. #' State and Territorial Epidemiologists Reports of Geographic Spread of Influenza
  2. #'
  3. #' @export
  4. #' @examples \dontrun{
  5. #' geographic_spread()
  6. #' }
  7. geographic_spread <- function() {
  8. meta <- jsonlite::fromJSON("https://gis.cdc.gov/grasp/Flu8/GetPhase08InitApp?appVersion=Public")
  9. httr::POST(
  10. url = "https://gis.cdc.gov/grasp/Flu8/PostPhase08DownloadData",
  11. httr::user_agent(.cdcfluview_ua),
  12. httr::add_headers(
  13. Origin = "https://gis.cdc.gov",
  14. Accept = "application/json, text/plain, */*",
  15. Referer = "https://gis.cdc.gov/grasp/fluview/FluView8.html"
  16. ),
  17. encode = "json",
  18. body = list(
  19. AppVersion = "Public",
  20. SeasonIDs = paste0(meta$seasons$seasonid, collapse=",")
  21. ),
  22. # httr::verbose(),
  23. httr::timeout(60)
  24. ) -> res
  25. httr::stop_for_status(res)
  26. res <- httr::content(res, as="parsed", flatten=TRUE)
  27. xdf <- dplyr::bind_rows(res$datadownload)
  28. xdf$weekend <- as.Date(xdf$weekend, format="%B-%d-%Y")
  29. xdf
  30. }