R/data-house-congress.R

Defines functions data_house_congress_extract data_house_congress_load data_house_congress_pipeline data_house_congress

Documented in data_house_congress data_house_congress_pipeline

#' @describeIn data House of Representatives - Congress
#' @export
data_house_congress <- function() {

  dataset_open(data_bucket("house/congress"))

}

#' @rdname data
data_house_congress_pipeline <- function() {

  scrape_session("https://congress.gov.ph/legisdocs/?v=ra") %>%
    data_house_congress_extract() %>%
    data_house_congress_load()

}

data_house_congress_load <- function(data) {

  data %>%
    dataset_write(data_bucket("house/congress"))

}

data_house_congress_extract <- function(session) {

  session %>%
    html_node("select[name='congress']") %>%
    html_nodes("option") %>% {
      tibble::tibble(
        congress_id = html_text(.),
        form_value  = html_attr(., "value")
      )
    }

}
tjpalanca/phlegis documentation built on Dec. 23, 2021, 10:59 a.m.