Skip to content

Instantly share code, notes, and snippets.

@sauceaaron
Last active November 14, 2019 00:40
Show Gist options
  • Save sauceaaron/14839e15f48802b4fb077d00ced367e5 to your computer and use it in GitHub Desktop.
Save sauceaaron/14839e15f48802b4fb077d00ced367e5 to your computer and use it in GitHub Desktop.
Using R with RSelenium to get data
# install and load the RSelenium package
install.packages("RSelenium")
require(RSelenium)
# connect to your selenium server
driver <- remoteDriver(remoteServerAddr = "localhost", port = 4444, browserName = "firefox")
# launch a browser and navigate to the page you want information from
driver$open()
driver$navigate("https://www.quora.com/How-do-you-use-R-via-Selenium-to-download-data-automatically/")
driver$getTitle()
# get data from the page
answers <- driver$findElement(using="class name", value="answer_count")
answercount <- answers$getElementText()
print(answercount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment