代码之家  ›  专栏  ›  技术社区  ›  Simba2015

将HTML代码读入R以进行数据和文本挖掘

  •  1
  • Simba2015  · 技术社区  · 11 年前

    我正在尝试将本网站上的信息读入R中进行数据和文本分析:

    http://www.nhl.com/scores/htmlreports/20142015/PL020916.HTM
    

    我已尝试使用以下包和代码将源代码读入R:

    library(XML)
    theurl <- "http://www.nhl.com/scores/htmlreports/20142015/PL020916.HTM"
    tables <- readHTMLTable(theurl)
    
    con = url("http://www.nhl.com/scores/htmlreports/20142015/PL020916.HTM")
    htmlCode=readLines(con)
    close(con)
    htmlCode
    

    我正在寻找一个输出,它是所提供信息的平面文件。

    1 回复  |  直到 11 年前
        1
  •  0
  •   cory    11 年前

    我不知道你在从你提供的页面中寻找什么信息,但下面是你如何使用rvest阅读它。。。

    url <- "http://www.nhl.com/scores/htmlreports/20142015/PL020916.HTM"
    library("rvest")
    url %>% html()