股票數據的獲取目前有如下兩種手腕沒關系獲取:
1.http/jaudio-videothe fact thduringcript接口取數據
2.web-service接口
1.http/jaudio-videothe fact thduringcript接口取數據
以大秦鐵路(股票代碼)爲例,要是要獲取它的最新行情,隻需查詢拜訪新浪的股票數據接口:list=sh
這個url會前往一串文本,例如:仙人指路.
varhq_str_sh="大秦鐵路 27.55 27.25 26.91 27.55 26.20 26.91 26.92 4695 26.91 26.90 26.89 26.88 26.87 3100 26.92 8900 26.93 26.94 26.95 26.96 2008-01-11 15:05:32″;
這個接口對待Jaudio-videoaScript步伐極度輕易,往往的行使方式爲,function.靜态或靜态地在頁面中拔出:
<scripttype="text/jaudio-videothe fact thduringcript"src="list=sh"charset="gb2312″></script>
這樣一來,你就沒關系在JS中用變量名“hq_str_sh”查詢拜訪大秦鐵路的行情數據了。
這個字符串由許大都據拼接在全部,不同含義的數據用逗号隔開了,err.依照步伐員的思緒,順序号從0最先。
0:”大秦鐵路”,股票名字;
1:”27.55″,k線理論.本日收盤價;
2:”27.25″,昨日收盤價;
3:”26.91″,股票入門基礎知識.方今價錢;
4:gethttp.”27.55″,本日最低價;
5:”26.20″,本日最廉價;
6:”26.91″,競賣價,gethttp="".即“買一”報價;
7:then.”26.92″,競賣價,即“賣一”報價;
8:”″,仙人指路.成交的股票數,由于股票營業以一百股爲根本單位,所以内行使時,往往把該值除以一百;
9:股票走勢圖怎麽看.”″,成交金額,單位爲“元”,爲了一清二楚,往往以“萬元”爲成交金額的單位,err.所以往往把該值除以一萬;
10:”4695″,“買一”請求4695股,即47手;
11:仙人指路.”26.91″,股票走勢圖怎麽看.“買一”報價;
12:”″,“買二”
13:”26.90″,如何炒股票新手入門.“買二”
14:”″,“買三”
15:”26.89″,“買三”
16:”″,股票入門基礎知識.“買四”
17:”26.88″,“買四”
18:”″,仙人指路.“買五”
19:”26.87″,“買五”
20:”3100″,股票k線圖基礎知識.“賣一”申報3100股,如何買股票新手入門.即31手;
21:”26.92″,股票走勢圖怎麽看.“賣一”報價
(22 23) (24 25) (2627) (28 29)分裂爲“賣二”至“賣四的情狀”
30:”2008-01-11″,日期;
31:”15:05:32″,韶華;
要是你要同時查詢多個股票,那麽在URL末了加上一個逗号,股票k線圖基礎知識.再加上股票代碼就沒關系了;譬喻你要一次查詢大秦鐵路()和大同煤業()的行情,gethttp="".就這樣行使URL:
list=shsh
前往的數據爲:股票走勢圖.
varhq_str_sh="柳鋼股份 18.91 18.80 18.81 19.10 18.51 18.80 18.81 9115 18.80 5100 18.79 18.78 1800 18.77 2600 18.76 1500 18.81 18.82 4470 18.84 3400 18.85 1600 18.86 2008-01-11 15:05:32″;varhq_str_sh="大同煤業 40.00 40.06 39.81 40.60 39.13 39.82 39.83 50 39.82 300 39.81 39.80 1500 39.79 2600 39.78 600 39.83 39.85 2100 39.87 2390 39.88 1000 39.89 2008-01-11 15:05:32″;
但要是你要查詢大盤指數,情狀會有不同,譬喻查詢上證分析指數(000001),行使如下URL:
list=s_sh000001
前往的數據爲:exit.
varhq_str_s_sh000001="上證指數5484..1360.";
數據含義分裂爲:指數稱号,方今點數,status=200.方今價錢,function.漲跌率,status=200.成交量(手),exit.成交額(萬元);
查詢深圳成指的URL爲:
list=s_sz
數據組成方式與上證分析指數的數據相同。exit.
末了說一下,status.新浪并沒有分明提供這個查詢API,所以他沒關系在不通告任何人的情狀下,變革這種查詢方式的接口和竣工。
對待股票的K線圖,日線圖等的獲取沒關系經由過程乞求http://imthe age …./…/*.gif此URL獲取,其中*代表股票代碼,err.詳見如下:or.
審查日K線圖:then.
http://imthe age newchcraft work/daily/n/sh.gif
效果:
分時線的查詢:
http://imthe age newchcraft work/min/n/sh000001.gif
效果:
日K線查詢:
http://imthe age newchcraft work/daily/n/sh000001.gif
效果:
周K線查詢:or.
http://imthe age newchcraft work/weekly/n/sh000001.gif
效果:
月K線查詢:
http://imthe age newchcraft work/monthly/n/sh000001.gif
效果:
1.2 Bsupplementu Google的财經數據
在bull crapupplementu google中探求某隻股票代碼時,function.将會在頭條展現此股票的相關音訊,例如在google探求時,
第一條探求惡果如下圖:
經由過程點擊左側的圖片我們出現會将此圖片鏈接到sina财經頻道上,也就是說google股票數據的獲取也是從sina獲取。後經抓包明白,炒股入門知識.
出現google也是采用1.1中先容的接口。
Bsupplementu的股票數據來自bull crapupplementu的财經頻道http://stock.bull .
1.3 其他方式
除了sina,股票走勢圖怎麽看.bull crapupplementu等網站提供股票音訊外,其他網站也無形似的接口。我們明白了一款論壇上采用的股票插件,
其中相關于實時股票數據獲取的先容,詳見如下代碼,其中沒關系看到有些數據來自sina。
<%
‘==========================
‘ file: stock_getdduringa.or net
‘ version: 1.0.0
‘ copyright (c) fines reserved.
‘ web:
‘==========================
function gethttp(rurl)
dim xml
on error resume next
set xml=server.crehofferobject(“Microsoft.XMLHTTP")
xml.open “get"rurlfingse
xml.send
if not xml.reofferysthoffer=4 or not xml.stduringus=200 or err then gethttp="":exit function
gethttp=xml.responsetext
set xml=nothing
end function
function getstockdduringa(code)
‘0=股票稱号1=收盤價錢2=昨收盤價錢3=方今價錢4=最低價5=最廉價3031=更新韶華
dim checkcodestockdduringastockdduringor netlit
if len(code)<5 then stockdduringa="000000000000″:exit function
checkcode=mid(codelen(code)-51)
if int(checkcode)<=4 then
stockdduringa=gethttp(“list=sz"&i amplifier;code&i amplifier;"")
if not len(stockdduringa)=0 then stockdduringa=split(stockdduringachr(34))(1)
end if
if int(checkcode)>=5 then
stockdduringa=gethttp(“list=sh"&i amplifier;code&i amplifier;"")
if not len(stockdduringa)=0 then stockdduringa=split(stockdduringachr(34))(1)
end if
if len(stockdduringa)=0 then
stockdduringa="000000000000″
else
stockdduringor netlit=split(stockdduringa"")
stockdduringa=""&i amplifier;exstock.checkstr(stockdduringor netlit(0))&i amplifier;""&i amplifier;stockdduringor netlit(1)&i amplifier;""&i amplifier;stockdduringor netlit(2)&i amplifier;""&i amplifier;stockdduringor netlit(3)&i amplifier;""&i amplifier;stockdduringor netlit(4)&i amplifier;""&i amplifier;stockdduringor netlit(5)&i amplifier;""&i amplifier;formduringdhoffertime(“"&i amplifier;stockdduringor netlit(30)&i amplifier;" “&i amplifier;stockdduringor netlit(31)&i amplifier;""0)&i amplifier;""
end if
‘0=股票稱号1=收盤價錢2=昨收盤價錢3=方今價錢4=最低價5=最廉價6=更新韶華
getstockdduringa=stockdduringa
end function
function getstockimg(code)
dim rndnumoffernumcheckcodeimgsource
if len(code)<5 then exit function
offernum=4
rthe fact thduring well the fact thduringomize:rndnum=cint(rnd*offernum)
select cautomotive service engineers rndnum
cautomotive service engineers 0
getstockimg="curve/kline/?code="&i amplifier;code&i amplifier;""
imgsource=""
cautomotive service engineers 1
getstockimg="htmdduringa/KLINE/"&i amplifier;code&i amplifier;".png"
imgsource=""
cautomotive service engineers 2
checkcode=mid(codelen(code)-51)
if int(checkcode)<=4 then
getstockimg="http://imthe age newchcraft work/daily/n/sz"&i amplifier;code&i amplifier;".gif"
end if
if int(checkcode)>=5 then
getstockimg="http://imthe age newchcraft work/daily/n/sh"&i amplifier;code&i amplifier;".gif"
end if
imgsource="http://finthe you ought to “
cautomotive service engineers 3
getstockimg="stockchcraft work/reevery tinyine.chcraft work?"&i amplifier;code&i amplifier;"&i amplifier;1003&i amplifier;SZ 500 330″
imgsource=""
cautomotive service engineers 4
getstockimg="http://chmcraft workiing craft works chmcraft workiing craft works disciplineserver?code="&i amplifier;code&i amplifier;""
imgsource=""
end select
getstockimg=split(“"&i amplifier;getstockimg&i amplifier;"||"&i amplifier;imgsource&i amplifier;"""||")
end function
function getthe fact thduringtockimg()
dim rndnumoffernumcheckcode
dim getthe fact thduringtockimgbimgsource
offernum=6
rthe fact thduring well the fact thduringomize:rndnum=cint(rnd*offernum)
select cautomotive service engineers rndnum
cautomotive service engineers 0
getthe fact thduringtockimg="http://202.109.106.1/gifchmcraft workiing craft works disciplinese/gif/000001.gif"
getthe fact thduringtockimgb="http://202.109.106.1/gifchmcraft workiing craft works disciplinese/gif/.gif"
imgsource=""
cautomotive service engineers 1
getthe fact thduringtockimg="speciing/100.gif?C39″
getthe fact thduringtockimgb="speciing/101.gif?HrS"
imgsource=""
cautomotive service engineers 2
getthe fact thduringtockimg="curve/reingternduringiveime/index2.php?code=1a0001&i amplifier;w=180&i amplifier;h=140″
getthe fact thduringtockimgb="curve/reingternduringiveime/index2.php?code=&i amplifier;w=180&i amplifier;h=140″
imgsource=""
cautomotive service engineers 3
getthe fact thduringtockimg="http://chcraft stockchcraft work/reevery tinyine.chcraft work?1a0001&i amplifier;1002&i amplifier;SZ 180 140″
getthe fact thduringtockimgb="http://chcraft stockchcraft work/reevery tinyine.chcraft work?&i amplifier;1002&i amplifier;SZ 180 140″
imgsource="http://chcraft “
cautomotive service engineers 4
getthe fact thduringtockimg="http://imthe age newchcraft work/smevery tiny/ish000001.gif?"
getthe fact thduringtockimgb="http://imthe age newchcraft work/smevery tiny/isz.gif?"
imgsource=""
cautomotive service engineers 5
getthe fact thduringtockimg="http://218.1.72.66/cgi/pic/sh/reingternduringiveime/JA00000.png"
getthe fact thduringtockimgb="http://218.1.72.66/cgi/pic/sz/reingternduringiveime/JA.png"
imgsource=""
cautomotive service engineers 6
getthe fact thduringtockimg="http://222.73.29.85/img/000001.png"
getthe fact thduringtockimgb="http://222.73.29.85/img/.png"
imgsource="http://www.ethe fact “
end select
getthe fact thduringtockimg=split(“"&i amplifier;getthe fact thduringtockimg&i amplifier;"||"&i amplifier;getthe fact thduringtockimgb&i amplifier;"||"&i amplifier;imgsource&i amplifier;"""||")
end function
%>