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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With