1
我正在嘗試爲Data Science 101項目刮冰球參考。我遇到了特定表格的問題。網頁是:https://www.hockey-reference.com/boxscores/201611090BUF.html。所需表格在「高級統計報告(所有情況)」下。我已經嘗試了以下代碼:使用rvest來刮取HTML數據
url="https://www.hockey-reference.com/boxscores/201611090BUF.html"
ret <- url %>%
read_html()%>%
html_nodes(xpath='//*[contains(concat(" ", @class, " "), concat(" ", "right", " "))]') %>%
html_text()
此代碼將從上表中刪除所有數據,但在高級表之前停止。我也試圖讓更多的顆粒具有:
url="https://www.hockey-reference.com/boxscores/201611090BUF.html"
ret <- url %>%
read_html()%>%
html_nodes(xpath='//*[(@id = "OTT_adv")]//*[contains(concat(" ", @class, " "), concat(" ", "right", " "))]') %>%
html_text()
其產生的「字符(0)」訊息話題。任何和所有的幫助,將不勝感激..如果它尚未明確,我相當新的R.謝謝!