码迷,mamicode.com
首页 > 编程语言 > 详细

R语言 批量下载财务报表

时间:2020-02-28 12:00:31      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:nan   fun   div   money   statement   cti   url   html   dataset   

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,"BS_",symbol,".xls",sep="");
  }
  if(type=="PS"){
    url=paste(pre,"ProfitStatement",mid,symbol,end,sep="");
    destfile=paste(file,"PS_",symbol,".xls",sep="");
  }
  if(type=="CF"){
    url=paste(pre,"CashFlow",mid,symbol,end,sep="");
    destfile=paste(file,"CF_",symbol,".xls",sep="");
  }
  download.file(url, destfile);
}
c=c("600550","600192","600152","600644","600885","600151")
for(i in 1:length(c)){
  code=c[i]
  getsheets(code,"BS","D://dataset//")
}

  

R语言 批量下载财务报表

标签:nan   fun   div   money   statement   cti   url   html   dataset   

原文地址:https://www.cnblogs.com/amosding/p/12376396.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!