【发布时间】:2016-03-31 11:18:53
【问题描述】:
我已使用 rvest 从 ESPNFC.co.uk 上的一场足球比赛中抓取评论,但我正在努力获得所需的最终输出。
library("rvest")
library("xlsx")
espnfc<-html("http://www.espnfc.co.uk/commentary/422421/commentary.html")
commentary<-espnfc %>%
html_nodes("#convo-window") %>%
html_text()
commentary <- gsub ( "\n", "", commentary)
commentary <- gsub ( "\r", "", commentary)
commentary <- gsub ( "\t", "", commentary)
最终输出是一个巨大的字符串,但是我希望每分钟的动作是数据框中的一行,例如:
"90'Second Half ends, Liverpool 2, Sunderland 2."
"90'Attempt blocked. Adam Johnson (Sunderland) right footed shot from outside the box is blocked. Assisted by Patrick van Aanholt."
"90'Attempt missed. Jordon Ibe (Liverpool) right footed shot from outside the box is close, but misses to the left. Assisted by Mamadou Sakho."
"90'Lucas Leiva (Liverpool) wins a free kick in the attacking half."
我该怎么办?
【问题讨论】: