Last active
November 14, 2019 00:40
-
-
Save sauceaaron/14839e15f48802b4fb077d00ced367e5 to your computer and use it in GitHub Desktop.
Using R with RSelenium to get data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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