免费股票行情接口:
1 sina 新浪js接口
http://hq.sinajs.cn/list=sh600001
返回
var hq_str_sh600011="华能国际,7.390,7.420,7.230,7.500,7.110,7.210,7.230,24257738,174459225.000,6200,7.210,9900,7.200,16000,7.190,24400,7.180,18506,7.170,23900,7.230,53100,7.240,50400,7.250,17000,7.260,2000,7.270,2018-12-17,15:00:00,00";
http://hq.sinajs.cn/list=sh600011,sh600012
返回
var hq_str_sh600011="华能国际,7.390,7.420,7.230,7.500,7.110,7.210,7.230,24257738,174459225.000,6200,7.210,9900,7.200,16000,7.190,24400,7.180,18506,7.170,23900,7.230,53100,7.240,50400,7.250,17000,7.260,2000,7.270,2018-12-17,15:00:00,00"; var hq_str_sh600012="皖通高速,5.590,5.590,5.620,5.650,5.550,5.610,5.620,2157530,12066336.000,16500,5.610,45971,5.600,11600,5.590,44300,5.580,19600,5.570,1200,5.620,19500,5.630,21300,5.640,57700,5.650,38100,5.660,2018-12-17,15:00:00,00";
返回格式如下:
股票名字,今日开盘价,昨日收盘价,当前价格,今日最高价,今日最低价,买一量,买一价,买二量,买二价,买三量,买三价,买四量,买四价,买五量,买五价,卖一量,卖一价,卖二量,卖二价,卖三量,卖三价,卖四量,卖四价,卖五量,卖五价,日期,时间
优点:实时数据,可以一次获取多个股票的当天实时数据,而且数据指标很全;
缺点:不能指定日期;
2 netease 网易csv下载接口
http://quotes.money.163.com/service/chddata.html?code=0600011&start=19940809&end=20181214&fields=TCLOSE;HIGH;LOW;TOPEN;LCLOSE;CHG;PCHG;TURNOVER;VOTURNOVER;VATURNOVER;TCAP;MCAP
返回
优点:可以指定起始和结束日期以及哪些数据指标,适合下载历史数据;
缺点:不实时;
代码如下:
val url = new URL(urlStr) val conn = url.openConnection val is = conn.getInputStream val bos = new ByteArrayOutputStream() val b = new Array[Byte](1024) var len = 0 do { len = is.read(b) if (len > 0) bos.write(b, 0, len) } while (len != -1) println(new String(bos.toByteArray, "GBK"))
原文地址:https://www.cnblogs.com/barneywill/p/10134882.html
时间: 2024-10-29 00:09:51