2015-06-14 50 views
2

[R readHTMLTable失敗當我在我的筆記本電腦上運行的線路來加載外部實體

table500 <- readHTMLTable('http://en.wikipedia.org/wiki/List_of_S%26P_500_companies')[[1]] 

它得到的數據。當我在我的桌面上運行它,我收到錯誤

Error: failed to load external entity "http://en.wikipedia.org/wiki/List_of_S%26P_500_companies". 

所以我猜這個問題有事情做,在我的桌面網絡設置,我沒有什麼可雖然絲毫的想法。有什麼建議麼?

+0

當我試圖使用getURL,我得到了「SSL證書問題」,這似乎像蠕蟲 – josephocles

+0

我已經使用'rvest'發佈瞭解決方案的全新即可。在上面的鏈接中使用'httr'包的解決方案適用於我。 – Metrics

回答

4

在我在評論中提到的鏈接中,您可以找到使用RCurlhttr包的解決方案。在這裏,我使用rvest包提供解決方案。

library(rvest) 
    kk<-html("http://en.wikipedia.org/wiki/List_of_S%26P_500_companies")%>% 
    html_table(fill=TRUE)%>% 
    .[[1]] //table 1 only 

head(kk) 
    Ticker symbol   Security SEC filings   GICS Sector    GICS Sub Industry Address of Headquarters 
1   MMM   3M Company  reports   Industrials   Industrial Conglomerates  St. Paul, Minnesota 
2   ABT Abbott Laboratories  reports   Health Care Health Care Equipment & Services North Chicago, Illinois 
3   ABBV    AbbVie  reports   Health Care     Pharmaceuticals North Chicago, Illinois 
4   ACN  Accenture plc  reports Information Technology IT Consulting & Other Services   Dublin, Ireland 
5   ACE   ACE Limited  reports    Financials Property & Casualty Insurance  Zurich, Switzerland 
6   ACT   Actavis plc  reports   Health Care     Pharmaceuticals   Dublin, Ireland 
    Date first added  CIK 
1     66740 
2      1800 
3  2012-12-31 1551152 
4  2011-07-06 1467373 
5  2010-07-15 896159 
6     884629 
相關問題