xml
  • r
  • 2016-03-05 63 views 0 likes 
    0

    我想使用R從網站上取消數據。我是新手在報廢數據。使用R從抓取數據從covers.com獲取錯誤

    我的代碼如下:

    library(XML) 
    url1<-"http://www.covers.com/sports/NCAAB/matchups?selectedDate=2015-02-28" 
    data1<-htmlTreeParse(url1) 
    getNodeSet(data1,"//div[@class = 'data-competition-type']") 
    

    然而,我等這樣的錯誤:

    Error in UseMethod("xpathApply") : 
        no applicable method for 'xpathApply' applied to an object of class "XMLDocumentContent" 
    

    爲什麼我得到這個eror?我會很樂意提供任何幫助。非常感謝。

    +1

    基本上,切換到'htmlParse' –

    回答

    2

    getNodeSetdoc論點在於,根據幫助頁面(見?getNodeSet),應該是「 類XMLInternalDocument的對象。」

    由於您的data1對象不是類「XMLInternalDocument」的對象;它是類「XMLDocumentContent」的一個對象

    相關問題