Skip to content

Instantly share code, notes, and snippets.

@yanping
Last active December 11, 2015 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanping/4545944 to your computer and use it in GitHub Desktop.
Save yanping/4545944 to your computer and use it in GitHub Desktop.
从复旦人民币汇率指数网站读取数据
# 从复旦人民币汇率指数网站读取数据 http://ifsfd.fudan.edu.cn/fdurmb/indexchart1.jsp
# 更多细节请看 http://cos.name/cn/topic/109132
require(RCurl)
require(rjson)
fdjson <- getURL("http://ifsfd.fudan.edu.cn/fdurmb/data?df=2000%2F01%2F03&type=0%2C1%2C2&dt=2013%2F01%2F16")
fdlist <- fromJSON(fdjson)
fdm <-matrix(unlist(fdlist),ncol=4,byrow=T)
fddf <- data.frame(fdm, stringsAsFactors = F)
fddf[,2] <- as.numeric(fddf[,2])
fddf[,3] <- as.numeric(fddf[,3])
fddf[,4] <- as.numeric(fddf[,4])
colnames(fddf) <- c("d","人民币名义有效汇率指数","人民币实际有效汇率指数","人民币盯住一篮子货币模拟汇率指数")
write.csv(fddf,"fudan1.csv",row.names = F )
fdjson2 <- getURL("http://ifsfd.fudan.edu.cn/fdurmb/data?df=2000%2F01%2F03&type=4%2C6&dt=2013%2F01%2F16")
fdlist2 <- fromJSON(fdjson2)
fdm2 <-matrix(unlist(fdlist2),ncol=3,byrow=T)
fddf2 <- data.frame(fdm2, stringsAsFactors = F)
fddf2[,2] <- as.numeric(fddf2[,2])
fddf2[,3] <- as.numeric(fddf2[,3])
colnames(fddf2) <- c("d","人民币盯住一篮子货币兑SDR模拟值","人民币兑SDR实际值")
write.csv(fddf2,"fudan2.csv",row.names = F )
fdjson3 <- getURL("http://ifsfd.fudan.edu.cn/fdurmb/data?dt=2013%2F01%2F16&df=2000%2F01%2F03&type=3%2C5%2C7")
fdlist3 <- fromJSON(fdjson3)
fdm3 <-matrix(unlist(fdlist3),ncol=4,byrow=T)
fddf3 <- data.frame(fdm3, stringsAsFactors = F)
fddf3[,2] <- as.numeric(fddf3[,2])
fddf3[,3] <- as.numeric(fddf3[,3])
fddf3[,4] <- as.numeric(fddf3[,4])
colnames(fddf3) <- c("d","人民币盯住一篮子货币兑USD模拟值","人民币兑USD实际值","人民币盯住一篮子货币兑USD模拟值")
write.csv(fddf3,"fudan3.csv",row.names = F )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment