I want to create a script in R to read an HTML table. Doing this from a static page with the rvest
package is easy, the problem is that I have to change the value of two buttons on the page.
The site is this here . Note that above the graph, it has two buttons: one related to status ( ctl00$cphConteudo$CpDDLEstado
) and other related to an agricultural product ( ctl00$cphConteudo$CpDDLProduto
).
I tried the following code with no success:
library(rvest)
url <- "http://www.agrolink.com.br/cotacoes/historico/rs/leite-1l"
pgsession <- html_session(url) ## create session
pgform <- html_form(pgsession)[[1]] ## pull form from session
filled_form <- set_values(pgform,
'ctl00$cphConteudo$CpDDLEstado' = "9826", #bahia
'ctl00$cphConteudo$CpDDLProduto' = "17") # algodão
submit_form(pgsession,filled_form)
The code returns a link from a blank page.