2
I’m trying to log into a site, the value site is merely illustrative, someone knows why the function is not working?
login <- function (xxxx_user, xxxx_pass) {
url_login <- 'http://www.valor.com.br/login'
curlhand <- getCurlHandle()
curlSetOpt(
.opts = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")),
cookiefile = "cookies.txt",
useragent = 'YOUR R-PACKAGE NAME',
followlocation = TRUE,
# might need this in case the server checks for the referer..
httpheader = "Referer: http://www.valor.com.br",
curl = curlhand)
# (1) first call to initializate session. you get the session cookie
getURL(url_login, curl = curlhand)
params<- list( login = xxxx_user, password = xxxx_pass )
# might need to add some other hidden form param in case there are..
# (2) second call, sends the form, along with a session cookie
html = postForm(url_login,
.params = params,
curl = curlhand,
style="POST")
# ... perform some grep logic with 'html' to find out weather you are connected
}
# you call the function...
login("seulogin", "suasenha")
This appears in R: Failed to connect to www.valor.com.br port 80: Timed out
Vlw!!!
What packages are you using?
– TheBiro
I’m using the Rcurl
– Danilo Imbimbo
Solved the issue?
– Tomás Barcellos