oscn_scrape_dates <- function(courts, casetypes, from_mdy, to_mdy, updatedb = FALSE) {
ctlist <- casetype_codes %>%
filter(casetype %in% casetypes)
from_m <- str_extract(from_mdy, "\\d{1,2}(?=(/|-))")
from_d <- str_extract(from_mdy, "(?<=(/|-))\\d{1,2}(?=(/|-))")
from_y <- str_extract(from_mdy, "(?<=(/|-))\\d{4}$")
to_m <- str_extract(to_mdy, "\\d{1,2}(?=(/|-))")
to_d <- str_extract(to_mdy, "(?<=(/|-))\\d{1,2}(?=(/|-))")
to_y <- str_extract(to_mdy, "(?<=(/|-))\\d{4}$")
for (l in courts) {
court_tmp <- l
for (k in ctlist$casetype_id) {
casetype_id <- k
d <- read_html(paste0("http://www.oscn.net/dockets/Results.aspx?db=",
str_remove_all(court_tmp, " "),
"&number=&lname=&fname=&mname=&DoBMin=&DoBMax=&partytype=&apct=&dcct=",
casetype_id,
"&FiledDateL=",
from_m, "%2F", from_d, "%2F", from_y,
"&FiledDateH=&ClosedDateL=&ClosedDateH=&iLC=&iLCType=&iYear=&iNumber=&citation="))
if (d %>% html_node("body") %>%
html_text() %>%
str_detect("Found No Records") == FALSE) {
d <- d %>%
html_node("table") %>%
html_table()
d$seq <- str_extract(d$`Case Number`, "(?<=-)\\d{1,5}($|A)") %>% str_remove_all("[[:alpha:]]") %>% as.numeric()
d$casetype <- str_extract(d$`Case Number`, "\\w{2}(?=-)")
from_seq <- min(d$seq)
}
d <- read_html(paste0("http://www.oscn.net/dockets/Results.aspx?db=",
str_remove_all(court_tmp, " "),
"&number=&lname=&fname=&mname=&DoBMin=&DoBMax=&partytype=&apct=&dcct=",
casetype_id,
"&FiledDateL=",
to_m, "%2F", to_d, "%2F", to_y,
"&FiledDateH=&ClosedDateL=&ClosedDateH=&iLC=&iLCType=&iYear=&iNumber=&citation="))
if (d %>% html_node("body") %>%
html_text() %>%
str_detect("Found No Records") == FALSE) {
d <- d %>%
html_node("table") %>%
html_table()
d$seq <- str_extract(d$`Case Number`, "(?<=-)\\d{1,5}($|A)") %>% str_remove_all("[[:alpha:]]") %>% as.numeric()
d$casetype <- str_extract(d$`Case Number`, "\\w{2}(?=-)")
to_seq <- max(d$seq)
}
oscn_scrape(courts = court_tmp, casetype = as.character(ctlist[ctlist$casetype_id == casetype_id, 1]),
years = as.numeric(from_y), case_seqs = from_seq:to_seq, updatedb = FALSE)
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.