当我在笔记本电脑上运行该线路时,
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".
所以我猜测这个问题与我桌面上的网络设置有关,但我一点也不知道它可能是什么。有什么建议么?
在我在评论中提到的链接中,您可以使用以下方法找到解决方案RCurl
and httr
包裹。在这里,我提供使用的解决方案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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)