2

Estou tentando logar em um site, o site do valor é meramente ilustrativo, alguém sabe pq a função não está dando certo?

  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")

Aparece isso na resposta do R: Failed to connect to www.valor.com.br port 80: Timed out

Vlw!!!

3
  • Está usando quais pacotes?
    – TheBiro
    22/02/2017 às 15:09
  • Estou usando o RCurl 22/02/2017 às 17:40
  • Resolveu a questão? 24/01/2019 às 20:22

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .