Being not an expert on web-programming, I attempt to automate a task which consists of getting into a website, download some csv files, and finally import them in R for data analysis.
In this context, I am working on the below sample code found on internet, which has been customized a bit to my need, and wonder to know more about the resulting error:
library(RCurl)
curl = getCurlHandle()
curlSetOpt(cookiejar = 'cookies.txt', followlocation = TRUE, autoreferer =
TRUE, curl = curl)
# Load the page for the first time to capture VIEWSTATE:
html <- getURL('http://ift.tt/21avmm9',
curl = curl,
.opts=list(ssl.verifypeer=FALSE))
# Extract VIEWSTATE with a regular expression or any other tool:
viewstate <- as.character(sub('.*id="__VIEWSTATE" value="([0-9a-zA-
Z+/=]*).*', '\\1', html))
# Set the parameters as your username, password and the VIEWSTATE:
params <- list(
'user' = '<USERNAME>',
'pass' = '<PASSWORD>',
'__VIEWSTATE' = viewstate
)
html = postForm('http://ift.tt/21avmm9',
.params = params, curl = curl,.opts=list(ssl.verifypeer=FALSE))
Error: Proxy Authentication Required
# Verify if you are logged in:
grepl('Logout', html)
[1]FALSE
Thanks
Aucun commentaire:
Enregistrer un commentaire