新浪股票接口失效解决方法,2022年访问接口出现 “Kinsoku jikou desu” 日语禁止访问

解决办法是在请求头部添加Referer字段

2022 新浪股票接口更新需要加Referer才能获取数据,接口:http://hq.sinajs.cn

接口用法:http://hq.sinajs.cn?list=sh601003

Referer:http://finance.sina.com.cn


结果:

var hq_str_sh601003="柳钢股份,4.120,4.170,4.100,4.140,4.050,4.090,4.100,7596745,31048892.000,225400,4.090,116600,4.080,167600,4.070,163600,4.060,367600,4.050,300,4.100,43300,4.110,15000,4.120,77400,4.130,77900,4.140,2022-05-10,11:30:00,00,";

字段说明:

var hq_str_sh601500="
0:    通用股份    //名字;
1:    5.050       //今日开盘价
2:    5.060       //昨日收盘价
3:    5.090       //当前价格
4:    5.110       //今日最高价
5:    5.030       //今日最低价
6:    5.090       //竞买价,即“买一”报价;
7:    5.100       //竞卖价,即“卖一”报价;
8:    3963000     //成交的股票数,转手乘100
9:    20106078.000//成交金额(元),转万除10000
10:    52800       //“买一”申请52800股
11:    5.090       //“买一”报价;
12:    90600       //“买二”申请90600股
13:    5.080       //“买二”报价;
14:    98500       //..
15:    5.070       //..
16:    105200      //..
17:    5.060       //..
18:    127900      //..
19:    5.050       //..
20:    104400      //“卖一”申报104400股
21:    5.100       //“卖一”报价;
22:    99700       //“卖二”申报99700股
23:    5.110       //“卖二”报价;
24:    111800      //..
25:    5.120       //..
26:    87500       //..
27:    5.130       //..
28:    73300       //..
29:    5.140       //..
30:    2022-08-27  //日期
31:  13:18:56   //时间`

代码:

用curl请求即可,太简单了,代码不贴了,编码是GB2312的,自己转换一下

curl_setopt($ch, CURLOPT_REFERER,'http://finance.sina.com.cn');