#代码的部分描述
## symbol:股票代码
## type: 报表类型。BS为资产负债表;PS为利润表;CF为现金流量表
## file: 存储下载文件的地址。比如file="D://"
# 1. 从新浪财经网上获取财务套表函数 getsheets <- function(symbol,type,file){ pre="http://money.finance.sina.com.cn/corp/go.php/vDOWN_"; mid="/displaytype/4/stockid/"; end="/ctrl/all.phtml"; if(type=="BS"){ url=paste(pre,"BalanceSheet",mid,symbol,end,sep=""); destfile=paste(file,"BalanceSheet_",symbol,".xls",sep=""); } if(type=="PS"){ url=paste(pre,"ProfitStatement",mid,symbol,end,sep=""); destfile=paste(file,"ProfitStatement_",symbol,".xls",sep=""); } if(type=="CF"){ url=paste(pre,"CashFlow",mid,symbol,end,sep=""); destfile=paste(file,"CashFlow_",symbol,".xls",sep=""); } download.file(url, destfile); } # 下载000065的资产负债表,并存放在D盘 getsheets("000065","BS","D://") trying URL 'http://money.finance.sina.com.cn/corp/go.php/vDOWN_BalanceSheet/displaytype/4/stockid/000065/ctrl/all.phtml' Content type 'application/vnd.ms-excel' length 200 bytes opened URL downloaded 18 KB Warning message: In download.file(url, destfile) : downloaded length 18884 != reported length 200