7

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

Sushanta Deb
  • 529
  • 8
  • 20

2 Answers2

5

You may change the option 'Btn_Login' = 'GO' to something like

'Btn_Login.x' = '22',
'Btn_Login.y' = '14'

According to this, the reason is a bug.

Some browsers (IIRC it is just some versions of Internet Explorer) only send the co-ordinates of the image map (in name.x and name.y) and ignore the value.

aristotll
  • 8,694
  • 6
  • 33
  • 53
1

If you are sure your credentials are correct you could try to add more additional curl setopt arguments, following this example in PHP. It's maybe also worth a try to monitor how your credentials are transferred. Maybe some extra encoding is necessary or unnecessary one added.

wp78de
  • 18,207
  • 7
  • 43
  • 71