I'm trying to scrape a table from the web (here https://www.cryptoslam.io/nba-top-shot/marketplace).
I have been researching how to do this and seem to have gotten closest using library rvest
and the html_table()
function. In fact I was able to download the "FIFA World Cup Record" table from here https://en.wikipedia.org/wiki/Brazil_national_football_team using the code
webpage_url <- "https://en.wikipedia.org/wiki/Brazil_national_football_team"
webpage <- xml2::read_html(webpage_url)
tbls <- html_nodes(webpage, "table")
head(tbls)
tbls_ls <- webpage %>%
html_nodes("table") %>%
.[[6]] %>%
html_table(fill = TRUE)
Note that I have the libraries library(xml2)
, library(rvest)
loaded. I then am using essentially the same code here:
webpage_url <- "https://www.cryptoslam.io/nba-top-shot/marketplace"
webpage <- xml2::read_html(webpage_url)
tbls <- html_nodes(webpage, "table")
head(tbls)
tbls_ls <- webpage %>%
html_nodes("table") %>%
.[[1]] %>%
html_table(fill = TRUE)
but getting the error
Error in matrix(NA_character_, nrow = n, ncol = maxp) :
invalid 'ncol' value (too large or NA)
In addition: Warning messages:
1: In max(p) : no non-missing arguments to max; returning -Inf
2: In matrix(NA_character_, nrow = n, ncol = maxp) :
NAs introduced by coercion to integer range
I have not been able to find any discussion of this error anywhere else. One thing that is different between the two tables is the existence of a thead
tag in the second one which won't work. I have quite limited knowledge of html so I may be missing some other important differences between the table implementations.
question from:
https://stackoverflow.com/questions/66054630/rvest-html-table-error-maxp-returning-inf 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…