rvest 1.0.0 - Latest Update Incompatibility

Viewed 88

The goal: Log in to a website using rvest.

The problem: My code no longer works with rvest (Version 1.0.0).

What worked: Code using the previous version of rvest (Version 0.3.6):

rg.headers <- c('User-Agent' = 'Mozilla/5.0')
rg.url <- "https://rotogrinders.com/"
rg.session <- html_session(rg.url, httr::add_headers(.headers=rg.headers))
rg.session <- rvest:::request_POST(rg.session, url = "https://rotogrinders.com/sign-in",
                                   body = list("username"="*****",
                                                "password"="*****"),
                                   encode = 'json')

My question: Can someone suggest a way to accomplish in rvest 1.0.0 what I was doing before with rvest 0.3.6? For the time being, I have reverted back 0.3.6 to keep things running smoothly.

1 Answers

I can´t comment with my reputation, which is why I will write an answer, even though I am not sure this makes any sense. I dont have a user-account, but with the following I got an "invalid username" result. Which makes sense to me. Maybe with a valid username this works?

headers <- c('User-Agent' = 'Mozilla/5.0')
url <- "https://rotogrinders.com/sign-in"
result <-  httr::POST(url = url,
                          httr::add_headers(.headers=headers),
                          body = list("username"="test",
                                      "password"="admin"),
                          encode = 'json')

Related