作为web-programming方面的专家,我试图自动完成一项任务,包括进入一个网站,下载一些csv文件,最后将它们导入R中进行数据分析。
在这种情况下,我正在编写在internet上找到的以下示例代码,这些代码已经根据我的需要进行了一些定制,并想知道更多关于由此产生的错误的信息:
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谢谢
发布于 2022-10-01 20:43:50
您可以考虑以下对我有用的方法:
library(RSelenium)
rd <- rsDriver(chromever = "105.0.5195.52", browser = "chrome", port = 4480L)
remDr <- rd$client
remDr$open()
url <- "https://www.olisnet.com/OlisAuthenticate/JSP/login.jsp"
remDr$navigate(url)
web_Obj_Id <- remDr$findElement("id", "PIN")
web_Obj_Id$sendKeysToElement(list("myusername"))
web_Obj_First_GoButton <- remDr$findElement("id", "boutonGo")
web_Obj_First_GoButton$clickElement()
web_Obj_Password <- remDr$findElement("id", "PWD")
web_Obj_Password $sendKeysToElement(list("mypassword"))
web_Obj_Second_GoButton <- remDr$findElement("css selector", "#form-step-2 > div > div > button")
web_Obj_Second_GoButton$clickElement()https://stackoverflow.com/questions/35480395
复制相似问题