5
I want to create a script in R to read an HTML table. Do this from a static page with the package rvest
is easy, the problem is that I have to change the value of two page buttons.
This is the site here. Note that above the graph, it has two buttons: one related to the state (ctl00$cphConteudo$CpDDLEstado
) and other related to an agricultural product (ctl00$cphConteudo$CpDDLProduto
).
I tried the following code unsuccessfully:
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.
Very good! It reminded me that I need to study regular expressions.
– iatowks