由于不是web-programming
方面的Maven,我尝试自动化一项任务,该任务包括进入一个网站,下载一些csv
文件,最后将它们导入R中进行数据分析。
在这种情况下,我正在工作下面的示例代码在互联网上找到,这已经定制了一点我的需要,并想知道更多关于产生的错误:
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('https://www.olisnet.com/OlisAuthenticate/JSP/login.jsp',
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('https://www.olisnet.com/OlisAuthenticate/JSP/login.jsp',
.params = params, curl = curl,.opts=list(ssl.verifypeer=FALSE))
Error: Proxy Authentication Required
# Verify if you are logged in:
grepl('Logout', html)
[1]FALSE
谢谢
1条答案
按热度按时间kx7yvsdv1#
您可以考虑以下对我有效的方法: