R - download CVM data via POST method (package httr)

7

I'm trying to build a function in R to download multiple documents directly from the system made available by the CVM.

The general instructions given by the CVM for the multiple download are described in: link

p>

In short, access to the system depends on authentication via login and password and requires that you inform the parameters of the query via POST method. The system will respond in XML, making the URLs available for downloading documents.

What I want to do is to return in the R the list containing these URLs. To do this, I tried to write a simple function using the package "httr", described below:

sist_cvm <- "https://www.rad.cvm.gov.br/DOWNLOAD/SolicitaDownload.asp"

login <- list(txtLogin = "MEU_LOGIN", txtSenha = "MINHA_SENHA", txtData = "15/04/2015", txtHora = "00:00", txtDocumento = "4")

library(httr)

acesso <- POST(url=sist_cvm, body=login, encode="multipart", verbose())

However, when trying to run, it returns the following error:

  

SSL certificate problem: Error in function (type, msg, asError = TRUE)

Note: I tried to make multiple combinations when composing the POST function, varying encode as form , multipart and json , as well as including or omitting verbose() . I also tried replacing the login and password elements of the login with authenticate("MEU_LOGIN", "MINHA_SENHA") list. In all cases, the same error was returned.

Could anyone give me any suggestions, please?

Thank you!

    
asked by anonymous 17.04.2015 / 18:23

1 answer

2

It seems that in the latest version of the httr package this problem is solved. Here is a code that worked:

cvm <- "https://WWW.RAD.CVM.GOV.BR/DOWNLOAD/SolicitaDownload.asp"

informs <- list(txtLogin = "seulogin", 
          txtSenha = "suasenha", 
          txtData = format(Sys.Date(), "%d/%m/%Y"), 
          txtHora = "00:00", 
          txtDocumento = "TODOS")

acesso <- POST(url = cvm, 
           body = informs, 
           encode = "form", 
           verbose())

Att.

    
17.09.2015 / 19:47