我正在尝试使用 R 登录http://etportfolio.economictimes.indiatimes.com/Login.htm以访问我在创建的投资组合中持有的股票。这是我收到消息“方法不允许”的脚本
library(RJSONIO)
library(rjson)
library(RCurl)
url <- ('http://etportfolio.economictimes.indiatimes.com/Login.htm')
agent="Firefox/23.0"
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
curl = getCurlHandle()
curlSetOpt( cookiejar = 'cookies.txt', useragent = agent, followlocation = TRUE ,
autoreferer = TRUE , curl = curl)
params <- list( 'ru' = "",
'nru' = "",
'loginPage' = "login",
'channel' = "portfolio",
'scriptTrackingCode' = "",
'nonscriptTrackingCode' = "",
'emailid' = "xxxx@hotmail.com",
'password' = "password")
html1 = postForm(url,.params = params,curl = curl, style = "POST", verbose=TRUE)
如果我尝试使用 httr 包,我可以获得登录成功,但需要有关如何前进的帮助。这是代码。
library(httr)
base_url <- ("http://etportfolio.economictimes.indiatimes.com/")
loginURL <- modify_url(
base_url,
path="/loginfrm.htm",
query = list(
title = "loginform",
action = "http://socialappsintegrator.indiatimes.com/socialsite/GenricSSOLogin?",
type = "login",
emailid = "xxx@hotmail.com",
password = "password" ) )
r <- POST(loginURL)
您能否帮助确定我是否犯了错误,或者有没有办法可以使用 R 进行身份验证?