require(RCurl)
#------------------------------------------
curl <- getCurlHandle()
curlSetOpt(
verbose = T,
cookiejar = 'cookies.txt' ,
followlocation = TRUE ,
ssl.verifypeer = FALSE,
useragent = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36',
curl = curl
)
#------------------------------------------
# list parameters to pass to the website (pulled from the source html)
your.username <- 'usuario'
your.password <- 'senha'
params <- list( 'txt_email' = your.username, 'txt_senha' = your.password)
# Realiza Login no Servidor
webAddr <- "
http://hostname.br/dirname/ct_login.php"
login <- postForm(webAddr, .params = params, curl = curl, style = 'POST')
login
[1] "1{Sucesso controller{Login efetuado"
attr(,"Content-Type")
charset "text/html" "ISO-8859-1" #------------------------------------------
# Realiza Busca
webBuscaId <- "
http://hostname.br/dirname/executa_busca.php"
busca <- postForm(webBuscaId,
.opts = list(httpheader = c('Content-Type' = 'application/json', ssl.verifypeer = FALSE)),
.params = list('idConsulta' = '13678616F',
'adicPar' = 'formatoNulo'),
curl = curl, style="POST")
* Hostname was found in DNS cache
* Trying 10.65.0.169...
* Connected to
xxxxxx.xxxxxx.xxx.br (10.65.0.169) port 80 (#3)
> POST /xxxxx/executa_busca.php HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36
Host: xxxxx.xxxx.xxx
.br
Accept: */*
Cookie: PHPSESSID=3dug68beqvmgpe0v19cc78a947
Content-Type: application/json
ssl.verifypeer: FALSE
Content-Length: 28
* upload completely sent off: 28 out of 28 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 500 Internal Server Error
< Date: Thu, 29 Oct 2015 12:53:27 GMT
< Server: Apache/2.2.15 (Red Hat)
< X-Powered-By: PHP/5.3.3
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Content-Length: 0
< Connection: close
< Content-Type: text/html; charset=ISO-8859-1
<
* Closing connection 3
Error: Internal Server Error
>