【发布时间】:2018-04-15 02:34:23
【问题描述】:
我正在尝试将这些数据解析为有意义的格式。我无法摆脱\t\n\t\t\t。请帮忙。
#Loading the rvest package
library('rvest')
# Define the url once.
URL <- "https://rotogrinders.com/pages/pga-course-history-743469"
tablescrape_html <- read_html(URL)
tablescrape_html
tablescrape_html %>%
html_nodes("table") %>%
head()
tablescrape_html %>%
html_nodes("tr") %>% #grab the <td> tags
html_text() %>% # isolate the text from the html tages
gsub("^\\s+|\\s+$", "", .) %>% #strip the white space from the beginning and end of a string.
head(n=100) # take a peek at the first 100 records
【问题讨论】:
-
你的标题说强制它到 data.frame 并且在描述中,它是删除
\t\n。如果最终输出是 data.frame,则不清楚列是什么
标签: r web-scraping data-science