试试这个。这将刮除所有表,合并它们,然后为列提供正确的名称。
library(tidyverse)
library(rvest)
levee_breaks_url <- read_html('https://secondhandsongs.com/performance/17982')
df <- levee_breaks_url %>%
html_nodes('.table') %>%
html_table() %>%
reduce(rbind) %>%
select(-1) %>%
rename_all(~levee_breaks_url %>%
html_nodes('th') %>%
html_text() %>%
.[2:5]) %>%
as.tibble()
df
#> # A tibble: 32 x 4
#> `Title ` `Performer ` `Release date ` Info
#> <chr> <chr> <chr> <chr>
#> 1 When the Leve⦠Kansas Joe and Memp⦠1929 First release
#> 2 When the Leve⦠John Campbell February 20, 19⦠""
#> 3 When the Leve⦠Clint Black 2005 ""
#> 4 When the Leve⦠Bennett Harris August 27, 2008 ""
#> 5 When the Leve⦠Buckwheat Zydeco 2009 ""
#> 6 Levee Breaks Beverley Martyn April 2014 ""
#> 7 When the Leve⦠Danny B. Harvey - M⦠October 14, 2014 ""
#> 8 When the Leve⦠Led Zeppelin November 8, 1971 First releaseSampâ¦
#> 9 When the Leve⦠Judge 1990 ""
#> 10 When the Leve⦠Rosetta Stone October 14, 1991 Unverified
#> # ... with 22 more rows
创建日期:2018-09-06
reprex
package
(第0.2.0版)。