table 的格式是 Lineups.com 以及如何在 R 中抓取它

What format of table is at Lineups.com and how to scrape it in R

我是新手,已经成功地从这些网站上抓取了表格:-

https://www.numberfire.com/nba/daily-fantasy/daily-basketball-projections/guards
https://www.dailyfantasyfuel.com/nba/projections/draftkings/
https://www.sportsline.com/nba/expert-projections/simulation/

但是这个网站:-

https://www.lineups.com/nba/nba-fantasy-basketball-projections

好像很棘手。

1.我试着把它读成 JSON

r <- read_html('https://www.lineups.com/nba/nba-fantasy-basketball-projections/') %>% html_element('script#__NEXT_DATA__') %>% html_text() %>% jsonlite::parse_json()

2。来自 rvest 方法

    data <- "https://www.lineups.com/nba/nba-fantasy-basketball-projections" %>%
      read_html %>%
      html_nodes('script') %>%
      html_text()

3。以及 RSelenium 但没有成功。

你能告诉我如何处理在“www.lineups.com”找到的这些类型的表格吗?

谢谢

使用RSelenium

library(RSelenium)
library(rvest)
library(dplyr)
driver = rsDriver(browser = c("firefox"))

remDr <- driver[["client"]]

url <- 'https://www.lineups.com/nba/nba-fantasy-basketball-projections'
remDr$navigate(url)

#get all the tables from webapage 
df = remDr$getPageSource()[[1]] %>% 
    read_html() %>% html_table()
[[2]]
# A tibble: 51 x 31
   Player   Player Player Player Player Player Player Player ``    ``    ``    ``    ``    ``    Game  Game  Game  Game  Game  `Projected Game~ `Projected Game~
   <chr>    <chr>  <chr>  <chr>  <chr>  <chr>  <chr>  <chr>  <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>            <chr>           
 1 "Name"   Team   Pos    Proje~ Salary Pts/$~ FPPM   USG%   Pos   Proj~ Sala~ Pts/~ FPPM  USG%  Opp   DvP   Spre~ Total O/U   MINS             PTS             
 2 "Nikola~ DEN    C      58.37  ,0~ 5.3    1.8    31.3%  HOU   30    13.5  126   238   33    27.7  7.7   13.7  1.1   0.9   5                18.8            
 3 "Gianni~ MIL    PF     57.84  ,3~ 5.1    1.8    35.1%  CHI   27    -5    122.~ 240   33    30.5  5.9   11.7  1     1.4   7.8              19.1            
 4 "Joel E~ PHI    C      53.35  ,8~ 4.9    1.7    37.4%  CLE   5     7     112   216.5 32    29.4  4.2   11    0.9   1.4   8.9              19