Используя следующую ссылку: http://webapps2.rrc.state.tx.us/EWA/drillingPermitsQueryAction.do
Я пытаюсь заполнить форму в R, отправить форму и извлечь результаты, которые получены путем нажатия кнопки «Скачать» на странице, котораяпоявляется после отправки первоначальной формы.
Код ниже описывает то, что я уже пробовал.Я не уверен насчет 1) правильно ли я отправляю форму или 2) как читать данные после отправки.
library(rvest)
library(httr)
baseURL <- "http://webapps2.rrc.state.tx.us/EWA/"
drillingPermit <- paste0(baseURL, "drillingPermitsQueryAction.do")
# Get the session of the URL
page <- html_session(drillingPermit)
# Create form
form <- html_form(page)[[1]]
# Fill out form
## County
form$fields$searchArgs.countyCodeHndlr.selectedCodes$value = "013"
## Purpose
form$fields$searchArgs.filingPurposeCodeHndlr.inputValue$value = "01"
## Date
form$fields$searchArgs.approvedDtFromHndlr.inputValue$value = "08/26/2019"
form$fields$searchArgs.approvedDtToHndlr.inputValue$value = "08/31/2019"
# Submit form
res <- submit_form(session = page, form = form)
# Exploratory work:
## I'm able to fetch some of the tables (except 6:11) but there's no sensible data there
table <- content %>% html_nodes("table")
table[[6]] %>% html_table(fill = TRUE)
## I've also tried using SelectorGadget to get the css
test <- html_nodes(res, css = 'tr:nth-child(11) td , tr:nth-child(10) td, tr:nth-child(9) td, tr:nth-child(8) td, tr:nth-child(7) td, tr:nth-child(6) td, tr:nth-child(5) td, tr:nth-child(4) td, .DataGrid tr:nth-child(3) td, th')