当前位置:网站首页>Kinsoku Jikou Desu Sina stock interface change
Kinsoku Jikou Desu Sina stock interface change
2022-06-23 19:45:00 【51CTO】
1、 Question why
The Sina stock interface returns the value shown in the title :Kinsoku jikou desu!
http://hq.sinajs.cn/list=code The interface change of Sina stock , You need to add... To the request header Referer value .
Data source site : Sina finance and economics _ Sina.com
2、 Core code
/// <summary>
/// Get Sina stock cache
/// </summary>
/// <param name="args"> The code requesting the query </param>
/// <returns></returns>
[
HttpGet,
HttpPost]
public
string
GetSinaStockCache(
string
args)
{
string
url
=
"http://hq.sinajs.cn/list="
+
args;
HttpWebRequest
request
= (
HttpWebRequest)
WebRequest.
Create(
url);
// Create a request example
// .NET Core edition
request.
Headers.
Add(
"Referer",
"https://finance.sina.com.cn/");
// .NET Framework edition
// request.Referer = "https://finance.sina.com.cn/";
HttpWebResponse
response
= (
HttpWebResponse)
request.
GetResponse();
// Get a response , Send the request
Stream
responseStream
=
response.
GetResponseStream();
StreamReader
streamReader
=
new
StreamReader(
responseStream,
Encoding.
Default);
// Default Chinese normal display ,UTF-8 Chinese can be garbled
string
json
=
streamReader.
ReadToEnd();
return
json;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
To avoid interface changes , You can write to the cache when you get the response value , Give cache a valid period , As long as the returned information is abnormal, you can read the cache .
Finally, I would like to thank Sina stock interface for its constant support and great God's foresight .
3、 test
Request parameters (args):sz000651
Return results :
"var hq_str_sz000651=\" Gree electric appliances ,39.300,39.220,38.640,39.300,38.520,38.640,38.640,42165560,1634520898.300,465667,38.640,57333,0.000,0,0.000,0,0.000,0,0.000,465667,38.640,0,0.000,0,0.000,0,0.000,0,0.000,2022-02-17,14:59:06,00\";\n"
That's all Kinsoku jikou desu! Introduction to the changes of Sina stock interface , Make this record , If help , Welcome to like, pay attention to collection !
边栏推荐
- Gaussdb (DWS) database intelligent monitoring operation and maintenance service - node monitoring indicators
- GL Studio 5 安装与体验
- Summary of accelerating mobile applications at network edge with software programmable FPGA
- JDBC 在性能测试中的应用
- Chaos engineering, learn about it
- Timertasks notes
- Are internal consultants and external consultants in SAP implementation projects difficult or successful?
- GL Studio 5 installation and experience
- 如何在Microsoft Exchange 2010中安装SSL证书
- 直播回顾 | 云原生混部系统 Koordinator 架构详解(附完整PPT)
猜你喜欢

为什么你的数据图谱分析图上只显示一个值?

不止雷军 iQOO产品经理也称赞高通骁龙8+:焕然一新

The evolution of the "Rainbow Bridge" middleware platform for the acquisition database based on shardingsphere

FlagAI飞智:AI基础模型开源项目,支持一键调用OPT等模型

20省市公布元宇宙路线图

如何通过7个步骤编写出色的在线用户手册

Rstudio 1.4 software installation package and installation tutorial

Function definition and function parameters

Development notes of wedding studio applet based on wechat applet

金九银十,靠这个细节,offer拿到手软!
随机推荐
游戏资产复用:更快找到所需游戏资产的新方法
技术分享| WVP+ZLMediaKit实现摄像头GB28181推流播放
Is it safe to make new debt
在线文本实体抽取能力,助力应用解析海量文本数据
Official announcement. Net 7 preview 5
SAP实施项目上的内部顾问与外部顾问,相互为难还是相互成就?
【云动向】华为云云商店品牌全新发布 4大亮点都在这儿
Elastricearch's fragmentation principle of the second bullet
OHOS LTS 3.0移植到RaspberryPi 4B
Not only Lei Jun, iqoo product manager, praised Qualcomm Xiaolong 8+: a new look
LeetCode 473. Match to square
JDBC 在性能测试中的应用
混沌工程,了解一下
如何利用数仓创建时序表
SQL联合查询(内联、左联、右联、全联)的语法
Kubernetes 资源拓扑感知调度优化
开源 SPL 重新定义 OLAP Server
Why is only one value displayed on your data graph?
Uniswap founder: no independent token will be issued for genie, and Genie products will be integrated into the uniswap interface
如何避免基因领域“黑天鹅”事件:一场预防性“召回”背后的安全保卫战