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
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
json , as well as including or omitting
verbose() . I also tried replacing the login and password elements of the
authenticate("MEU_LOGIN", "MINHA_SENHA") list. In all cases, the same error was returned.
Could anyone give me any suggestions, please?
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())