database – File download by filling in a form


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:


url <- ("")
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?


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

destfile = "")
Scroll to Top