rvest函数html_nodes返回{xml_nodeset(0)} [英] rvest function html_nodes returns {xml_nodeset (0)}
问题描述
我正在尝试在以下网站上抓取数据框
I am trying to scrape data frame the following website
http://stats.nba.com/game/0041700404/playbyplay/
我想创建一个表格,其中包含比赛日期,整个比赛的得分以及球队名称
I'd like to create a table that includes the date of the game, the scores throughout the game, and the team names
我正在使用以下代码:
game1 <- read_html("http://stats.nba.com/game/0041700404/playbyplay/")
#Extracts the Date
html_nodes(game1, xpath = '//*[contains(concat( " ", @class, " " ), concat( " ", "game-summary-team--vtm", " " ))]//*[contains(concat( " ", @class, " " ), concat( " ", "game-summary-team__lineup", " " ))]')
#Extracts the Score
html_nodes(game1, xpath = '//*[contains(concat( " ", @class, " " ), concat( " ", "status", " " ))]//*[contains(concat( " ", @class, " " ), concat( " ", "score", " " ))]')
#Extracts the Team names
html_nodes(game1, xpath = '//*[contains(concat( " ", @class, " " ), concat( " ", "game-summary-team__name", " " ))]//a')
不幸的是,我得到了以下
Unfortunately, I get the following
{xml_nodeset (0)}
{xml_nodeset (0)}
{xml_nodeset (0)}
我已经看到了很多关于这个问题的问题和答案,但是似乎都没有帮助.
I have seen a bunch of questions and answers to this problem but none of them seem to help.
推荐答案
我在R中的启动程序包中获得了成功.要安装,您需要docker.在下面列出的网站中提到了安装说明
I had success with the splashr package in R. To install you need docker. Installation instructions are mentioned in the websites listed below
https://cran.r-project.org/web/packages/splashr/vignettes/intro_to_splashr.html
https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac -如何在Mac上安装和运行Docker
https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac - how to install and run docker on a mac
https://splash.readthedocs.io/en/stable/install.html-在使用启动程序之前,在终端窗口中输入这些代码
https://splash.readthedocs.io/en/stable/install.html - type these codes into the terminal window before using splashr
这篇关于rvest函数html_nodes返回{xml_nodeset(0)}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!