database – File download by filling in a form

Question:

I'm trying to access a website, fill out their form, and download the file, but I'm having some difficulties.

This is my code so far:

#library's
require(rvest)

#website
url <- ("http://www.anbima.com.br/est_termo/Curva_Zero.asp")
pgsession <- html_session(url)
pgform <-html_form(pgsession)[[1]]
param <- set_values(pgform, 
        "escolha" = "2",
        "Dt_Ref" = Sys.Date()
)

submit <- submit_form(pgsession, form = param, "Consultar")

But it returns an error when submitting the submit: Erro: Could not find possible submission target.

Can someone help me?

Answer:

As discussed with the friend above, the result was much easier than imagined:

download.file("http://www.anbima.com.br/est_termo/CZ-down.asp", 
destfile = "")
Scroll to Top