使用R进行刮取,仅在列表中刮取第一个实例

使用R进行刮取,仅在列表中刮取第一个实例,r,rvest,R,Rvest,我已经搜刮了一些网站,并没有真正的问题,我的输出,但我不明白为什么在这个特定的网站上,我只得到了我试图搜刮的第一个实例,而不是全部36个 我正在尝试收集页面上所有玩家的href链接,并将它们保存到列表或数据框中 我目前的代码是: library(XML) library(rvest) match <- "https://www.fotball.no/fotballdata/kamp/?fiksId=6616922" WSm <- read_html(match) Players &l

我已经搜刮了一些网站,并没有真正的问题,我的输出,但我不明白为什么在这个特定的网站上,我只得到了我试图搜刮的第一个实例,而不是全部36个

我正在尝试收集页面上所有玩家的
href
链接,并将它们保存到列表或数据框中

我目前的代码是:

library(XML)
library(rvest)
match <- "https://www.fotball.no/fotballdata/kamp/?fiksId=6616922"
WSm <- read_html(match)
Players <- WSm %>% html_node(".player-name") %>% html_attr("href") %>% as.character()
并非如我所期望的,所有玩家的
href
s完整列表。有人能帮忙吗

不要使用html\u节点()

库(XML)
图书馆(rvest)
将%as.character()匹配
球员
>库(XML)
>图书馆(rvest)
正在加载所需的包:xml2
附加包:“rvest”
以下对象已从“package:XML”中屏蔽:
xml
>匹配WSm播放器%html\u节点(“.player name”)%%>%html\u attr(“href”)%%>%as.character()
>球员
[1] “/fotballdata/person/profil/?fiksId=2820074”“/fotballdata/person/profil/?fiksId=2775969”
[3] “/fotballdata/person/profil/?fiksId=2774767”“/fotballdata/person/profil/?fiksId=2820044”
[5] “/fotballdata/person/profil/?fiksId=2820232”“/fotballdata/person/profil/?fiksId=2820027”
[7] “/fotballdata/person/profil/?fiksId=2820034”“/fotballdata/person/profil/?fiksId=2799892”
[9] “/fotballdata/person/profil/?fiksId=2820237”“/fotballdata/person/profil/?fiksId=2799883”
[11] “/fotballdata/person/profil/?fiksId=2847997”“/fotballdata/person/profil/?fiksId=2830200”
[13] “/fotballdata/person/profil/?fiksId=2820235”“/fotballdata/person/profil/?fiksId=2779315”
[15] “/fotballdata/person/profil/?fiksId=2820241”“/fotballdata/person/profil/?fiksId=279908”
[17] “/fotballdata/person/profil/?fiksId=2820240”“/fotballdata/person/profil/?fiksId=2860570”
[19] “/fotballdata/person/profil/?fiksId=2795482”“/fotballdata/person/profil/?fiksId=2764974”
[21]“/fotballdata/person/profil/?fiksId=2795481”“/fotballdata/person/profil/?fiksId=2794122”
[23]“/fotballdata/person/profil/?fiksId=2852202”“/fotballdata/person/profil/?fiksId=2863826”
[25]“/fotballdata/person/profil/?fiksId=2811850”“/fotballdata/person/profil/?fiksId=2863824”
[27]“/fotballdata/person/profil/?fiksId=2800983”“/fotballdata/person/profil/?fiksId=2867153”
[29]“/fotballdata/person/profil/?fiksId=2811916”“/fotballdata/person/profil/?fiksId=2780695”
[31]“/fotballdata/person/profil/?fiksId=2811908”“/fotballdata/person/profil/?fiksId=2980432”
[33]“/fotballdata/person/profil/?fiksId=2904191”“/fotballdata/person/profil/?fiksId=2806897”
[35]“/fotballdata/person/profil/?fiksId=2794123”

使用
html\u节点()
(复数),而不是
html\u节点()
(单数)脏袜子嗅探器-是的。我刚在发帖的时候看到了你的答案。
[1] "/fotballdata/person/profil/?fiksId=2820074"
library(XML)
library(rvest)
match <- "https://www.fotball.no/fotballdata/kamp/?fiksId=6616922"
WSm <- read_html(match)
Players <- WSm %>% html_nodes(".player-name") %>% html_attr("href") %>% as.character()
Players

> library(XML)
> library(rvest)
Loading required package: xml2

Attaching package: ‘rvest’

The following object is masked from ‘package:XML’:

    xml

> match <- "https://www.fotball.no/fotballdata/kamp/?fiksId=6616922"
> WSm <- read_html(match)
> Players <- WSm %>% html_nodes(".player-name") %>% html_attr("href") %>% as.character()
> Players
 [1] "/fotballdata/person/profil/?fiksId=2820074" "/fotballdata/person/profil/?fiksId=2775969"
 [3] "/fotballdata/person/profil/?fiksId=2774767" "/fotballdata/person/profil/?fiksId=2820044"
 [5] "/fotballdata/person/profil/?fiksId=2820232" "/fotballdata/person/profil/?fiksId=2820027"
 [7] "/fotballdata/person/profil/?fiksId=2820034" "/fotballdata/person/profil/?fiksId=2799892"
 [9] "/fotballdata/person/profil/?fiksId=2820237" "/fotballdata/person/profil/?fiksId=2799883"
[11] "/fotballdata/person/profil/?fiksId=2847997" "/fotballdata/person/profil/?fiksId=2830200"
[13] "/fotballdata/person/profil/?fiksId=2820235" "/fotballdata/person/profil/?fiksId=2779315"
[15] "/fotballdata/person/profil/?fiksId=2820241" "/fotballdata/person/profil/?fiksId=2799908"
[17] "/fotballdata/person/profil/?fiksId=2820240" "/fotballdata/person/profil/?fiksId=2860570"
[19] "/fotballdata/person/profil/?fiksId=2795482" "/fotballdata/person/profil/?fiksId=2764974"
[21] "/fotballdata/person/profil/?fiksId=2795481" "/fotballdata/person/profil/?fiksId=2794122"
[23] "/fotballdata/person/profil/?fiksId=2852202" "/fotballdata/person/profil/?fiksId=2863826"
[25] "/fotballdata/person/profil/?fiksId=2811850" "/fotballdata/person/profil/?fiksId=2863824"
[27] "/fotballdata/person/profil/?fiksId=2800983" "/fotballdata/person/profil/?fiksId=2867153"
[29] "/fotballdata/person/profil/?fiksId=2811916" "/fotballdata/person/profil/?fiksId=2780695"
[31] "/fotballdata/person/profil/?fiksId=2811908" "/fotballdata/person/profil/?fiksId=2980432"
[33] "/fotballdata/person/profil/?fiksId=2904191" "/fotballdata/person/profil/?fiksId=2806897"
[35] "/fotballdata/person/profil/?fiksId=2794123"