调用股票实时信息代码–新浪的股票查询接口
以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据接口:http://hq.sinajs.cn/list=sh601006
这个url会返回一串文本,例如:
1 | 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"; |
这个接口对于JavaScript程序非常方便,通常的使用方式为,静态或动态地在页面中插入:
1 | <script type="text/javascript" src="http://hq.sinajs.cn/list=sh601006" charset="gb2312"></script> |
这样一来,你就可以在JS中用变量名“hq_str_sh601006”访问大秦铁路的行情数据了。
这个字符串由许多数据拼接在一起,不同含义的数据用逗号隔开了,按照程序员的思路,顺序号从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″,“买一”申请4695股,即47手;
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″,“卖一”申报3100股,即31手;
21:”26.92″,“卖一”报价
(22, 23), (24, 25), (26,27), (28, 29)分别为“卖二”至“卖四的情况”
30:”2008-01-11″,日期;
31:”15:05:32″,时间;
如果你要同时查询多个股票,那么在URL最后加上一个逗号,再加上股票代码就可以了;比如你要一次查询大秦铁路(601006)和大同煤业(601001)的行情,就这样使用URL:
http://hq.sinajs.cn/list=sh601003,sh601001
返回的数据为:
1 2 | var hq_str_sh601003="柳钢股份, 18.91, 18.80, 18.81, 19.10, 18.51, 18.80, 18.81, 5125000, 96017794, 9115, 18.80, 5100, 18.79, 12000, 18.78, 1800, 18.77, 2600, 18.76, 1500, 18.81, 25283, 18.82, 4470, 18.84, 3400, 18.85, 1600, 18.86, 2008-01-11, 15:05:32"; var hq_str_sh601001="大同煤业, 40.00, 40.06, 39.81, 40.60, 39.13, 39.82, 39.83, 8117292, 324759633, 50, 39.82, 300, 39.81, 22809, 39.80, 1500, 39.79, 2600, 39.78, 600, 39.83, 10600, 39.85, 2100, 39.87, 2390, 39.88, 1000, 39.89, 2008-01-11, 15:05:32"; |
但如果你要查询大盘指数,情况会有不同,比如查询上证综合指数(000001),使用如下URL:
http://hq.sinajs.cn/list=s_sh000001
返回的数据为:
1 | var hq_str_s_sh000001="上证指数,5484.677,28.136,0.52,877247,15587495"; |
数据含义分别为:指数名称,当前点数,当前价格,涨跌率,成交量(手),成交额(万元);
查询深圳成指的URL为:
http://hq.sinajs.cn/list=s_sz399001
数据构成方式与上证综合指数的数据相同。
最后说一下,新浪并没有明确提供这个查询API,所以他可以在不通知任何人的情况下,改变这种查询方式的接口和实现。
对于股票的K线图,日线图等的获取可以通过请求http://image.sinajs.cn/…./…/*.gif此URL获取,其中*代表股票代码,详见如下:
查看日K线图:
http://image.sinajs.cn/newchart/daily/n/sh601006.gif
分时线的查询:
http://image.sinajs.cn/newchart/min/n/sh000001.gif
日K线查询:
http://image.sinajs.cn/newchart/daily/n/sh000001.gif
周K线查询:
http://image.sinajs.cn/newchart/weekly/n/sh000001.gif
月K线查询:
http://image.sinajs.cn/newchart/monthly/n/sh000001.gif
大家QQ好友里有没有已过世的朋友,他们最后的签名是什么? Jquery判断复选框处于选中状态的个数方法
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Hi,
I just visited limingkai.com and wondered if you’ve ever considered an impactful video to advertise your business? Our videos can generate impressive results on both your website and across social media.
Our prices start from just $195.
Let me know if you’re interested in seeing samples of our previous work.
Regards,
Joanna
Hi there,
We run an Instagram growth service, which increases your number of followers both safely and practically.
– We guarantee to gain you 700-1500+ followers per month.
– People follow because they are interested in your profile, increasing likes, comments and interaction.
– All actions are made manually by our team. We do not use any ‘bots’.
The price is just $40 (USD) per month, and we can start immediately.
If you have any questions, let me know, and we can discuss further.
Kind Regards,
Gemma
Hi,
I just wanted to share an a YouTube A-Z system that guides you to build a thriving YouTube business, and here’s the revolutionary part: it comes with full private label rights (PLR) to sell as your own.
This 55+ page blueprint covers:
Foundation Blueprint: Niche, audience, and channel optimization.
Content Engine: Creating videos people want to watch.
Growth Accelerator: Demystifying the algorithm, SEO, and clickable thumbnails.
Monetization Machine: Unlocking 7+ income streams, including sponsorships.
The real game-changer is the PLR! You get permission to:
Sell this eBook and keep 100% of the money.
Put your name on it as the author.
Use it as a high-value bonus, break it into articles, or build your email list.
We’ve done the hard work; you get to profit instantly and build your authority.
But that’s not all. You’ll also receive the Complete Creator’s Launch Kit absolutely FREE! This bonus kit includes:
1. Pro Channel Branding Kit: Logo templates, YouTube intro/outro logos, end screens, channel art, lower third graphics, and a YouTube thumbnail bundle.
2. Viral Video Essentials: YT motion graphics, title animations, video transitions, animated subscribe buttons, and YouTube ranking tools.
3. Audio Engineer’s Sound Pack: Royalty-free background music, popular YouTuber sound effects, and transition sound effects.
Find out more here:
https://furtherinfo.info/ytmastery
Best regards,
Sterling
文章不错,学到了