1

I am trying to write a set of R codes to take screenshots from a password-protected website. I have tried using the webshot and httr packages but could not figure out a solution for this. Below are the codes that I have tried.

library(httr)
library(webshot)

handle <- handle("url of the home page")
path <- "url of login page"
login <- list(username = "my username", password = "my password", redirect_url = "url of the page that I want to screenshot")

response <- POST(handle = handle, path = path, body = login)

webshot("url of the page that I want to screenshot", "screenshot.png")

The screenshot shows the login page instead of the page that I want to screenshot. Which means that the website has not been logged in yet before the screenshot is taken. Can anyone help me?

debster
  • 333
  • 2
  • 10
  • 2
    Generally there is hesitation on SO when questions appear to be asking for assistance with violations of TOS or subverting copyright or accessing proprietary data. – IRTFM Oct 12 '21 at 03:31

1 Answers1

0

You can do this easily with the RSelenium package. This allows you to fill in the username and password and also has a screenshot function that can take a screenshot of a webpage and save that to disk.

Steve G. Jones
  • 325
  • 2
  • 10
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 23 '21 at 08:34