I'm trying to log into bondora.com with using R httr POST request, because this site does not appear to be using authentication:
library(httr)
login <- "https://www.bondora.com/en/login"
pars <- list(
username = "MyUserName",
password = "MyPassword"
)
POST(login, body = pars)
After logging in, the website directs the user back to landing page bondora.com/en/home, but instead if I parse the the POST request I get the same title for the page as the one from the login page:
library(XML)
test <- POST(login, body = pars)
test <- content(test, as = "text")
parsedHtml <- htmlParse(test, asText = TRUE)
xpathSApply(parsedHtml, "//title", xmlValue)
[1] "Join or log in|Loans and investing|Bondora"
I tried using the same techinque on some other sites and it appeared to be working quite fine, except for this site. The output from the POST command is as follows:
POST(login, body = pars)
Response [https://www.bondora.com/en/login]
Status: 200
Content-type: text/html; charset=utf-8
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
...
Are there some specific settings I should use for logging in on to bondora.com/en/login?
UPDATE 1 As per @hadley comment, I tired setting multipart TRUE and FALSE, but no help. Then I inspected the request via browser and added the same header:
login <- "https://www.bondora.com/en/authenticate"
pars <- list(
username = "username",
password = "password"
)
headers <- list(
"User-Agent" = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0",
"Referer" = "https://www.bondora.com/en/login?returnurl=/en/home",
"Host" = "www.bondora.com",
"Connection" = "keep-alive",
"Accept-Language" = "en-US,en;q=0.5",
"Accept-Encoding" = "gzip, deflate",
"Accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
)
POST(login, body = pars, add_headers(.headers = character(headers)))
Error in character(headers) : invalid 'length' argument
It seems that I would need to specify the length argument as did the HTML Error 411 indicate. How should I do that? I also tried adding Content-Length = 9844
to the Request Header as it was in the Response Header, but no success either.