恒有数(https://udata.hs.net/home?channel_source=vnpy

HTTP协议简介

HTTP是一个客户端终端(用户)和服务器端(网站)请求和应答的标准(TCP)。通过使用网页浏览器、网络爬虫或者其它的工具,客户端发起一个HTTP请求到服务器上指定端口,HTTP服务器则在那个端口监听客户端的请求。一旦收到请求,服务器会向客户端返回请求的文件、错误消息、或者其它信息。

可以通过Postman软件,简单快速实现http取数,也可生成各类编程语言的取数代码。

Postman实现http接口取数

Postman是一款非常流行的API调试工具,简单方便,而且功能强大。

Postman安装包下载地址为https://www.getpostman.com/apps ,支持MAC、Windows和Linux。

Postman的取数过程:

(1)新建请求;

(2)设置请求方式和URL地址(支持GET和POST请求);

(3)在Headers中设置token;在Params中设置输入参数;

(4)点击Send发送请求;

description

编程语言实现http接口取数

可以使用Postman自动生成各种编写语言调用http接口的代码,包括Python、Java、C、PHP、Shell等等

description

description

例如:Python - http.client

import http.client
​
conn = http.client.HTTPSConnection("udata.sit.hs.net")
payload = ''
headers = {
 'Application-Token': 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
}
conn.request("GET", "/light_data/business/v1/app_services/juyuan_basicdata/stock_list?secu_market=83", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

例如: JavaScript - Fetch

var myHeaders = new Headers();
myHeaders.append("Application-Token", "xxxxxxxxxxxxxxxxxxxxxxxxxxx");
​
var requestOptions = {
 method: 'GET',
 headers: myHeaders,
 redirect: 'follow'
};
​
fetch("https://udata.sit.hs.net/light_data/business/v1/app_services/juyuan_basicdata/stock_list?secu_market=83", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));