Skip to content

Commit

Permalink
Minor update to find correct URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
jensenmj committed Sep 23, 2024
1 parent c0a6cda commit 020c7b7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions data_development/get_ospi_equity_indicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library(dplyr)
library(stringr)
library(data.table)
library(RSocrata)
library(rvest)

# Setup: List necessary variables and lookups -----------------------

Expand Down Expand Up @@ -72,15 +73,17 @@ ospi_efa_to_elmer <- function(rs_kready){
# Identify URL -----------------------------------------------------

get_wadata_ospi_url <- function(year){
url_rgx <- "^https://data.wa.gov/education/Report-Card-WaKids-.*-School-Year"
schoolyr_txt <- paste0(year-1, "-",year %% 100)
wadata_search_url <- paste0("https://data.wa.gov/browse?q=Report%20Card%20WaKids%20",
schoolyr_txt,
"%20School%20Year&sortBy=relevance&limitTo=datasets")
return_term <- paste0("https://data.wa.gov/education/Report-Card-WaKids-", schoolyr_txt,"-School-Year/")
# Get first search result
fetched <- read_html(wadata_search_url)
fetched <- rvest::read_html(wadata_search_url)
links <- fetched %>% html_elements("a") %>% html_attr("href")
singleyear_code <- grep("https://data.wa.gov/education/Report-Card-WaKids-", links, value=TRUE)[1] %>% stringr::str_replace(return_term,"")
singleyear_code <- grep(url_rgx, links, value=TRUE)[1] %>%
stringr::str_replace(url_rgx,"")
api_url <- paste0("https://data.wa.gov/resource", singleyear_code, ".json")
return(api_url)
}
Expand Down Expand Up @@ -135,11 +138,12 @@ get_k_readiness <- function(URL){

# Example -----------------------------------------------------------
## Single year
# url <- get_wadata_ospi_url(2024)
# url <- get_wadata_ospi_url(2025)
# kready <- get_k_readiness(url)

## All years
# urlvector <- c("https://data.wa.gov/resource/vumg-9sgs.json", # 2023-24
# urlvector <- c("https://data.wa.gov/resource/3ji8-ykgj.json", # 2024-25
# "https://data.wa.gov/resource/vumg-9sgs.json", # 2023-24
# "https://data.wa.gov/resource/3ji8-ykgj.json", # 2022-23
# "https://data.wa.gov/resource/rzgf-vi75.json", # 2021-22
# # 2020-21 Not reported/collected
Expand Down

0 comments on commit 020c7b7

Please sign in to comment.