天天看点

[转] 获取实时股票数据与股票数据接口API

?$エ?版?????峰????????濡?涓?涓ょ??规???浠ヨ?峰??:

1.http/javascript?ュ?e???版??

2.web-service?ュ??

1.http/javascript?ュ?e???版??

1.1Sina?$エ?版???ュ?? 浠ュぇ绉???璺?锛??$エ浠g??锛?601006锛?涓轰?锛?濡???瑕??峰??瀹??????拌???锛?????璁块???版氮???$エ?版??

?ュ?o?http://hq.sinajs.cn/list=sh601006杩?涓?url浼?杩???涓?涓叉????锛?渚?濡?锛?

var hq_str_sh601006="澶хЕ??璺?, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92,

22114263, 589824680, 4695, 26.91, 57590, 26.90, 14700, 26.89, 14300,

26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, 2008-01-11, 15:05:32";

杩?涓?瀛?绗?覆?辫?稿??版???兼?ュ?ㄤ?璧凤?涓?????涔????版???ㄩ???烽??寮?浜?锛????х?搴???????璺?锛?椤哄??蜂?0寮?濮???

0锛???澶хЕ??璺???锛??$エ??瀛?锛?

1锛???27.55?筹?浠??ュ???浠凤?

2锛???27.25?筹??ㄦ?ユ?剁??浠凤?

3锛???26.91?筹?褰???浠锋?硷?

4锛???27.55?筹?浠??ユ??楂?浠凤?

5锛???26.20?筹?浠??ユ??浣?浠凤?

6锛???26.91?筹?绔?涔颁环锛??斥??涔颁????ヤ环锛?

7锛???26.92?筹?绔???浠凤??斥????涓????ヤ环锛?

8锛???22114263?筹???浜ょ???$エ?帮??变??$エ浜ゆ??浠ヤ??捐?′负?烘????浣?锛???浠ュ?ㄤ娇?ㄦ?讹???甯告??璇ュ?奸?や互涓??撅?

9锛???589824680?筹???浜ら??棰?锛???浣?涓衡??????锛?涓轰?涓???浜??讹???甯镐互??涓?????涓烘??浜ら??棰?????浣?锛???浠ラ??甯告??璇ュ?奸?や互涓?涓?锛?

10锛???4695?筹???涔颁????宠??695?★???7??锛?

11锛???26.91?筹???涔颁????ヤ环锛?

12锛???57590?筹???涔颁???

13锛???26.90?筹???涔颁???

14锛???14700?筹???涔颁???

15锛???26.89?筹???涔颁???

16锛???14300?筹???涔板????

17锛???26.88?筹???涔板????

18锛???15100?筹???涔颁???

19锛???26.87?筹???涔颁???

20锛???3100?筹?????涓????虫??100?★???1??锛?

21锛???26.92?筹?????涓????ヤ环

(22, 23), (24, 25), (26,27), (28, 29)????涓衡????浜????斥???????????碘??

30锛???2008-01-11?筹??ユ??锛?

31锛???15:05:32?筹??堕?达?

杩?涓??ュ?e?逛?JavaScript绋?搴???甯告?逛究锛???甯哥??浣跨?ㄦ?瑰?涓猴????????ㄦ???板?ㄩ〉??腑???ワ?

<script type="text/javascript" src="http://hq.sinajs.cn/list=sh601006" charset="gb2312">

</script>

<script type="text/javascript">

var elements=hq_str_sh601006.split(",");

document.write("current price:"+elements[3]);

</script>

杩?娈典唬??杈??哄ぇ绉???璺?锛??$エ浠g??锛?601006锛???褰????′环

current price:14.20

濡???浣?瑕????舵?ヨ?㈠?涓??$エ锛??d???RL??????涓?涓?涓????凤?????涓??$エ浠g??灏卞??浠ヤ?锛?姣?濡?浣?瑕?涓?娆℃?ヨ?㈠ぇ绉???璺?锛?601006锛???澶у???や?锛?601001锛???琛???锛?灏辫??蜂娇??RL锛?

http://hq.sinajs.cn/list=sh601003,sh601001

浣?濡???浣?瑕??ヨ?㈠ぇ?????帮????典???涓???锛?姣?濡??ヨ???璇?缁煎?????帮?000001锛?锛?浣跨?ㄥ?涓?URL锛?

http://hq.sinajs.cn/list=s_sh000001 ???″?ㄨ??????版??涓猴?

var hq_str_s_sh000001="涓?璇?????3094.668,-128.073,-3.97,436653,5458126";

?版????涔?????涓猴????板??绉帮?褰????规?帮?褰???浠锋?硷?娑ㄨ???锛???浜ら??锛???锛?锛???浜ら?锛?涓???锛?锛?

?ヨ?㈡繁?虫??????URL涓猴?

http://hq.sinajs.cn/list=s_sz399001

瀵逛??$エ??K绾垮?撅??ョ嚎?剧?????峰????浠ラ??杩?璇锋?http://image.sinajs.cn/??/??*.gif姝?RL?峰??锛??朵腑*浠h〃?$エ浠g??锛?璇??濡?涓?锛?

?ョ????绾垮?撅?

http://image.sinajs.cn/newchart/daily/n/sh601006.gif

???剁嚎???ヨ???

http://image.sinajs.cn/newchart/min/n/sh000001.gif

??绾挎?ヨ???

http://image.sinajs.cn/newchart/daily/n/sh000001.gif

??绾挎?ヨ???

http://image.sinajs.cn/newchart/weekly/n/sh000001.gif

??K绾挎?ヨ???

http://image.sinajs.cn/newchart/monthly/n/sh000001.gif

2. web-service?ュ??

2.1 CHINAstock??web-service锛?

http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx

涓??借?$エ琛????版?? WEB ???★?????娣卞?冲??涓?娴疯?″????ㄩ?ㄥ?洪?????哄?稿???$エ锛?锛??版???虫?舵?存?般??杈???IF???惰蛋?垮?俱???????? K 绾垮?俱?????惰????版??锛??$エ??绉般??琛????堕?淬?????颁环???ㄦ?剁????浠?寮?????娑ㄨ?棰?????浣?????楂???娑ㄨ?骞?????浜ら??????浜ら???绔?涔颁环??绔???浠枫??濮?姣???涔颁? - 涔颁?????涓? - ??浜?锛???姝?EB???℃??渚?浜?濡?涓???涓??ュ?o?

2.1.1 getStockImageByCode

GET ?$エGIF???惰蛋?垮??

INput锛?theStockCode = ?$エ浠e?凤?濡?锛?sh000001

POST /WebServices/ChinaStockWebService.asmx HTTP/1.1

Host: www.webxml.com.cn

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: http://WebXml.com.cn/getStockImageByCode

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<getStockImageByCode xmlns="http://WebXml.com.cn/">

<theStockCode>string</theStockCode>

</getStockImageByCode>

</soap:Body>

</soap:Envelope>

Output锛?

2.1.2 getStockImageByteByCode

?峰?涓??借?$エGIF???惰蛋?垮?惧?????扮?

INput锛?theStockCode = ?$エ浠e?凤?濡?锛?sh000001

POST /WebServices/ChinaStockWebService.asmx HTTP/1.1Host: www.webxml.com.cnContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://WebXml.com.cn/getStockImageByteByCode" <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getStockImageByteByCode xmlns="http://WebXml.com.cn/"> <theStockCode>string</theStockCode> </getStockImageByteByCode> </soap:Body></soap:Envelope>

杩??????版??濡?涓?锛?

<?xml version="1.0" encoding="utf-8" ?>

<base64Binary xmlns="http://WebXml.com.cn/">R0lGODlhIQIsAfcAAAAAAAwLBxkGBQ4ODhAQEBsSChUVFS4TDB8eGQkA9koPCDAAzy4mFVgAp2UYC0IqEUYuBVwiDEAsI1QnFX8AgDU1NUozFlgxD6cBWVY5FnIwEmQ4Gc0AMlhDHPEADlVJMEpKSm1IHOUBWpY3FZMyVY9IGXRWIEFmWGNYUmpdPXJgHQB8HK9EGGBgX4lXIACoAHhkMyt4m4VkJtstbv8A

2.1.3 getStockImage_kByCode

?存?ヨ?峰?涓??借?$エGIF?????? K 绾垮?撅?545*300pixel/72dpi锛?

INPUT: theStockCode = ?$エ浠e??

theType = K 绾垮?剧被??锛?D锛???榛?璁???W锛??ㄣ??M锛???锛?锛?

POST /WebServices/ChinaStockWebService.asmx HTTP/1.1Host: www.webxml.com.cnContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://WebXml.com.cn/getStockImage_kByCode" <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getStockImage_kByCode xmlns="http://WebXml.com.cn/"> <theStockCode>string</theStockCode> <theType>string</theType> </getStockImage_kByCode> </soap:Body></soap:Envelope>

姣?濡????т??炬??绀鸿??ワ?

杩?????缁???灏辨????绾垮?撅?

2.1.4 getStockImage_kByteByCode

?峰?涓??借?$エGIF?????? K 绾垮?惧?????扮?

Input锛?theStockCode = ?$エ浠e?凤?濡?锛?sh000001

POST /WebServices/ChinaStockWebService.asmx HTTP/1.1Host: www.webxml.com.cnContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://WebXml.com.cn/getStockImage_kByteByCode" <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getStockImage_kByteByCode xmlns="http://WebXml.com.cn/"> <theStockCode>string</theStockCode> <theType>string</theType> </getStockImage_kByteByCode> </soap:Body></soap:Envelope>HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Content-Length: length <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getStockImage_kByteByCodeResponse xmlns="http://WebXml.com.cn/"> <getStockImage_kByteByCodeResult>base64Binary</getStockImage_kByteByCodeResult> </getStockImage_kByteByCodeResponse> </soap:Body></soap:Envelope>姣?濡????т??捐???

杩?????缁???灏辨????绾垮?惧?????扮?

<?xml version="1.0" encoding="utf-8" ?>

<base64Binary xmlns="http://WebXml.com.cn/">R0lGODlhIQIsAfcAAAAAAAwLBxkGBQ4ODhAQEBsSChUVFS4TDB8eGQkA9koPCDAAzy4mFVgAp2UYC0IqEUYuBVwiDEAsI1QnFX8AgDU1NUozFlgxD6cBWVY5FnIwEmQ4Gc0AMlhDHPEADlVJMEpKSm1IHOUBWpY3FZMyVY9IGXRWIEFmWGNYUmpdPXJgHQB8HK9EGGBgX4lXIACoAHhkMyt4m4VkJtstbv8A

2.1.5 getStockInfoByCode

?峰?涓??借?$エ???惰???

input锛?theStockCode = ?$エ浠e??

POST /WebServices/ChinaStockWebService.asmx HTTP/1.1Host: www.webxml.com.cnContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://WebXml.com.cn/getStockInfoByCode" <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getStockInfoByCode xmlns="http://WebXml.com.cn/"> <theStockCode>string</theStockCode> </getStockInfoByCode> </soap:Body></soap:Envelope>杩??????间?涓?涓?缁村??绗?覆?扮? String(24)锛?缁???涓猴?String(0)?$エ浠e?枫??String(1)?$エ??绉般??String(2)琛????堕?淬??String(3)???颁环锛???锛???String(4)?ㄦ?剁??锛???锛???String(5)浠?寮???锛???锛???String(6)娑ㄨ?棰?锛???锛???String(7)??浣?锛???锛??? String(8)??楂?锛???锛???String(9)娑ㄨ?骞?锛?%锛???String(10)??浜ら??锛???锛???String(11)??浜ら?锛?涓???锛???String (12)绔?涔颁环锛???锛???String(13)绔???浠凤???锛???String(14)濮?姣?锛?%锛???String(15)-String(19)涔颁? - 涔颁?锛???锛?/????String(20)-String(24)??涓? - ??浜?锛???锛?/????

Web service???规?绫讳技浜??板??oncurrent椤圭????DBWS?版?????峰??锛??芥????杩?SOAP??璁???DBWS???″?ㄨ?峰???稿?崇???版????

?╃?ㄩ?????ヤ腑?借?$エ

http://quote.yahoo.com/d/quotes.csv?s=MSFT&f=slc1wop

杩???寰?杞????$エ浠锋??

"MSFT","4:00pm - <b>30.70</b>",+1.04,"21.46 - 30.75",29.77,29.66

http://quote.yahoo.com/d/quotes.csv?s=000969.SZ&f=slc1wop

杩?涓?杩???瀹?娉扮?????锛?涓???????涓?灏??剁??寤惰???

浣???s=000969.sz 杩?涓????㈢??sz??浠?涔????????

娣卞??)

娌?甯???SS??缂?

继续阅读