3

I think this can be done but I do not know if the functionality exists. I have searched the internet ans stack high and low and can not find anything. I'd like to save www.espn.com as an image to a certain folder on my computer at a certain time of day. Is this possible? Any help would be very much appreciated.

  • Related: http://stackoverflow.com/questions/762162/how-can-i-programmatically-create-a-screen-shot-of-a-given-web-site and http://stackoverflow.com/questions/12986820/converting-webpage-into-image-using-javascript/12986864#12986864 Possibly running these ideas with `system` – Tyler Rinker Feb 26 '14 at 19:00

1 Answers1

1

Selenium allows you to do this. See http://johndharrison.github.io/RSelenium/ . DISCLAIMER I am the author of the RSelenium package. The image can be exported as a base64 encoded png. As an example:

# RSelenium::startServer() # start a selenium server if required
require(RSelenium)
remDr <- remoteDriver()
remDr$open()
remDr$navigate("http://espn.go.com/")
# remDr$screenshot(display = TRUE) # to display image
tmp <- paste0(tempdir(), "/tmpScreenShot.png")
base64png <- remDr$screenshot()
writeBin(base64Decode(base64png, "raw"), tmp)

The png will be saved to the file given at tmp.

A basic vignette on operation can be viewed at RSelenium basics and RSelenium: Testing Shiny apps

jdharrison
  • 30,085
  • 4
  • 77
  • 89