library(rvest)
root_node <- read_html("https://en.wikipedia.org/wiki/List_of_bicycle-sharing_systems")
table_nodes <- html_nodes(root_node, "table")
for (i in 1) {
table_html <- table_nodes[[i]]
table_df <- html_table(table_html)
print(table_df)
}
A tibble: 549 × 10
Country City Name System Operator Launched Discontinued Stati…¹ Bicyc…² Daily…³
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 Albania Tirana[5] Ecovolis "" "" March 2011 "" 8 200 ""
2 Argentina Buenos Aires[6][7] Ecobici "Serttel Brasil[8]" "Bike In Baires Consortium[9]" 2010 "" 400 4000 "21917"
3 Argentina Mendoza[10] Metrobici "" "" 2014 "" 2 40 ""
4 Argentina Rosario Mi Bici Tu Bici[11] "" "" 2 December 2015 "" 47 480 ""
5 Argentina San Lorenzo, Santa Fe Biciudad "Biciudad" "" 27 November 2016 "" 8 80 ""
6 Australia Melbourne[12] Melbourne Bike Share "PBSC & 8D" "Motivate" June 2010 "30 November 2… 53 676 ""
7 Australia Melbourne[12] oBike "4 Gen. oBike" "" July 2017 "July 2018" dockle… 1250 ""
8 Australia Brisbane[14][15] CityCycle "3 Gen. Cyclocity" "JCDecaux" September 2010 "" 150 2000 ""
9 Australia Sydney oBike "4 Gen. oBike" "" July 2017 "July 2018" dockle… 1250 ""
10 Australia Sydney Ofo "4 Gen. Ofo" "" October 2017 "" dockle… 600 ""
# … with 539 more rows, and abbreviated variable names ¹Stations, ²Bicycles, ³`Daily ridership`
# ℹ Use `print(n = ...)` to see more rows
>
2条答案
按热度按时间lnlaulya1#
这里有一个简单的方法。提取第一个
"table.wikitable"
节点,然后从该节点提取表。创建于2023-04-10带有reprex v2.0.2
sqxo8psd2#
我们可以这样做: