導航:首頁 > 數據行情 > 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實現新浪股票數據介面相關的資料

熱點內容
股票中途買入漲停了怎麼辦 瀏覽:967
股票流動資金指標源代碼 瀏覽:736
建研院股票開盤時間 瀏覽:799
世有科技股票行情 瀏覽:388
香港人買了哪些中國股票 瀏覽:718
股票賬戶9幾年 瀏覽:57
騰訊員工入職購買股票 瀏覽:881
股票各指標意思 瀏覽:315
股票9點42漲停 瀏覽:733
恆星科技股票會退市嗎 瀏覽:250
銀行可以持有企業股票嗎 瀏覽:228
股票投資與私幕合作 瀏覽:681
中國股票在荷蘭上市後怎麼交易 瀏覽:565
股票資金流入流出說明什麼 瀏覽:320
不同時間發行的股票 瀏覽:37
恆信東方股票走勢 瀏覽:865
欣天科技股票7月2日解禁股 瀏覽:553
寶泰隆股票投資前景 瀏覽:783
洛陽鉬業股票主力一直流出 瀏覽:878
股票賬戶凈轉入 瀏覽:670