首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用{RCurl}的代理身份验证

使用{RCurl}的代理身份验证
EN

Stack Overflow用户
提问于 2016-02-18 11:37:38
回答 1查看 320关注 0票数 1

作为web-programming方面的专家,我试图自动完成一项任务,包括进入一个网站,下载一些csv文件,最后将它们导入R中进行数据分析。

在这种情况下,我正在编写在internet上找到的以下示例代码,这些代码已经根据我的需要进行了一些定制,并想知道更多关于由此产生的错误的信息:

代码语言:javascript
复制
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

谢谢

EN

回答 1

Stack Overflow用户

发布于 2022-10-01 20:43:50

您可以考虑以下对我有用的方法:

代码语言:javascript
复制
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()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35480395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档