R- 将维基百科列表抓取到 table
R- Scraping Wikipedia list in to a table
我正在尝试创建 U.S 的 table。使用 R 的维基百科页面 (https://en.wikipedia.org/wiki/List_of_hub_airports) 列表中的枢纽机场。我是网络抓取的新手,所以任何帮助或建议都将不胜感激。我正在尝试使用来自每个 U.S 的信息获得类似于以下内容的 table。状态。
Example of airport hub table
谢谢!
尽管整个项目将是一个挑战,但这里是拉取美国数据的开始。
library(rvest)
site <- "https://en.wikipedia.org/wiki/List_of_hub_airports"
txt <- read_html(site) %>%
html_nodes("#mw-content-text :nth-child(1)") %>%
html_text()
usatext <- txt[1866:2329]
我正在尝试创建 U.S 的 table。使用 R 的维基百科页面 (https://en.wikipedia.org/wiki/List_of_hub_airports) 列表中的枢纽机场。我是网络抓取的新手,所以任何帮助或建议都将不胜感激。我正在尝试使用来自每个 U.S 的信息获得类似于以下内容的 table。状态。
Example of airport hub table
谢谢!
尽管整个项目将是一个挑战,但这里是拉取美国数据的开始。
library(rvest)
site <- "https://en.wikipedia.org/wiki/List_of_hub_airports"
txt <- read_html(site) %>%
html_nodes("#mw-content-text :nth-child(1)") %>%
html_text()
usatext <- txt[1866:2329]