Here is some example code to provide more information. After downloading Docker and running docker run -d -p 4445:4444 selenium/standalone-chrome inside terminal, the following should work on your local machine (it does on mine):
library(shiny)
library(RSelenium)
ui <- fluidPage(
actionButton("go", "Scrape")
)
server <- function(input, output, session) {
observeEvent(input$go, {
remDr <- RSelenium::remoteDriver(remoteServerAddr = "localhost",
port = 4445L,
browserName = "chrome")
# Open browser session
remDr$open()
remDr$navigate("https://www.google.com/") # or any website
# Click on links and scrape some stuff
# Close browser session
remDr$close()
})
}
shinyApp(ui, server)
The problem is that this does not work when you publish to shinyapps.io. It must have something to do with the way I set up Docker, remoteServerAddr = "localhost", the port, etc., but I do not know how to solve this so that users can interact with my shinyApp to scrape websites that use javascript. Thanks for any help!