導航:首頁 > 數據行情 > java實現新浪股票數據介面

java實現新浪股票數據介面

發布時間:2024-09-01 14:53:25

① 請問怎樣用Java獲取股票行情歷史數據新浪、搜狐、百度財經都可以......

publicclassStockConnection{
publicstaticvoidmain(String[]args){
URLur=null;
try{
//搜狐股票行情歷史介面
// ur=newURL("http://q.stock.sohu.com/hisHq?code=cn_300228&start=20130930&end=20131231&stat=1&order=D&period=d&callback=historySearchHandler&rt=jsonp");
//新浪股票行情歷史介面
ur=newURL("http://biz.finance.sina.com.cn/stock/flash_hq/kline_data.php?&rand=random(10000)&symbol=sh600000&end_date=20150809&begin_date=20000101&type=plain");
HttpURLConnectionuc=(HttpURLConnection)ur.openConnection();
BufferedReaderreader=newBufferedReader(newInputStreamReader(ur.openStream(),"GBK"));
Stringline;
while((line=reader.readLine())!=null){
System.out.println(line);
}
}catch(Exceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
}
}

② 新浪JAVA API返回的JSON數據裡面中文亂碼

這是unicode編碼,不是亂碼,你進行Unicode轉碼就出來了

給你寫個方法轉碼,將unicode傳遞進去返回字元串

	publicStringconvert(StringutfString){
StringBuildersb=newStringBuilder();
inti=-1;
intpos=0;

while((i=utfString.indexOf("\u",pos))!=-1){
sb.append(utfString.substring(pos,i));
if(i+5<utfString.length()){
pos=i+6;
sb.append((char)Integer.parseInt(utfString.substring(i+2,i+6),16));
}
}

returnsb.toString();
}
閱讀全文

與java實現新浪股票數據介面相關的資料

熱點內容
投資股票應學習什麼專業 瀏覽:212
上市公司破產重組員工股票 瀏覽:165
中信建投手機股票交易軟體 瀏覽:835
科創板股票詳細信息 瀏覽:418
藍凌軟體股票在哪上市 瀏覽:544
股票數據實時介面 瀏覽:923
深圳壹藝科技有限公司股票 瀏覽:617
泳泳科技股票 瀏覽:532
美元疲軟股票走勢分析 瀏覽:437
股票賬戶如何利用好資金 瀏覽:846
人死後股票賬戶如何 瀏覽:30
重組成功下跌的股票 瀏覽:842
中國移動股票數據 瀏覽:963
上海星環信息科技股票代碼 瀏覽:858
中國製造相關股票代碼 瀏覽:791
有一些股票投資群 瀏覽:359
股票訓練營app官網版 瀏覽:871
目前破凈資產的股票 瀏覽:446
2020年萬科股票分紅時間 瀏覽:744
速鋒科技股票代碼 瀏覽:382