Css selector issue with rvest and NHL statistics

那年仲夏 提交于 2019-12-02 10:45:17
Brian L

You can try using RSelenium. Saw a similar answer here: Web Scraping Basketball Reference using R.

library(rvest)
library(RSelenium)
startServer() 
remDr<-remoteDriver(browserName = "chrome")
remDr$open()

remDr$navigate("https://www.hockey-reference.com/leagues/NHL_1991.html")
page <- read_html(remDr$getPageSource()[[1]])
table <- html_table(page, fill = TRUE)
table[[28]]

It's a pain to install selenium though and I would try to help with that too but I installed it a while ago so don't really remember. Good luck


From the guy who posted the original question:

The above answer worked, but I had to go through Homebrew:

https://brew.sh/

And then I had to use the following code from here:

Using Selenium on Mac Chrome

# download selenium jar
curl -L0 https://selenium-release.storage.googleapis.com/3.9/selenium- 
server-standalone-3.9.1.jar -o selenium-server-standalone.jar

# install chromedriver
brew install chromedriver

# start chrome driver
brew services start chromedriver                                                                                                                                                                      
#==> Successfully started `chromedriver` 
(label:homebrew.mxcl.chromedriver)

# start selenium server
java -jar selenium-server-standalone.jar                                                                                                                                                                           
#14:38:20.684 INFO - Selenium build info: version: '3.9.1', revision: 
'63f7b50'
#14:38:20.685 INFO - Launching a standalone Selenium Server on port 
4444
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!