Login to .NET site using R

Viewed 563

I am trying to login with my credentials to a .NET site but unable to get it working. My code is inspired from the below thread

How to login and then download a file from aspx web pages with R

library(RCurl)
curl = getCurlHandle()
curlSetOpt(cookiejar = 'cookies.txt', followlocation = TRUE, autoreferer = TRUE, curl = curl)
html <- getURL('http://www.aceanalyser.com/Login.aspx', curl = curl)
viewstate <- as.character(sub('.*id="__VIEWSTATE" value="([0-9a-zA-Z+/=]*).*', '\\1', html))
viewstategenerator <- as.character(sub('.*id="__VIEWSTATEGENERATOR" value="([0-9a-zA-Z+/=]*).*', '\\1', html))

params <- list(
  'txtUserID'    = '********',
  'txtPwd'    = '*******',
  'Btn_Login' = 'GO',
  '__VIEWSTATE' = viewstate,
  '__VIEWSTATEGENERATOR' = viewstategenerator,
  'HiddenField1' = '1280',
  'HiddenField2' = '700',
  'Hdn_Pwd' = 'true')

html = postForm('http://www.aceanalyser.com/Login.aspx', .params = params, curl = curl)
grepl('Logout', html)

Result: FALSE

Please help me understand the issue

2 Answers
Related