kepware http接口 nodejs开发
2024-09-13 12:15:52
读取某变量的值(native
var http = require("http"); var options = {
"method": "GET",
"hostname": [
"127",
"0",
"0",
"1"
],
"port": "39321",
"path": [
"iotgateway",
"read"
],
"headers": {
"Connection": "keep-alive",
"Cache-Control": "max-age=0",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
}
}; var req = http.request(options, function (res) {
var chunks = []; res.on("data", function (chunk) {
chunks.push(chunk);
}); res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
}); req.end();
读取某变量的值(request
var request = require("request"); var options = { method: 'GET',
url: 'http://127.0.0.1:39321/iotgateway/read',
qs: { ids: [ 'Channel1.Device1.tag1', 'Channel1.Device1.tag2' ] },
headers:
{'cache-control': 'no-cache',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36',
'Upgrade-Insecure-Requests': '1',
'Cache-Control': 'max-age=0',
Connection: 'keep-alive' } }; request(options, function (error, response, body) {
if (error) throw new Error(error); console.log(body);
});
读取某变量的值(unirest
var unirest = require("unirest"); var req = unirest("GET", "http://127.0.0.1:39321/iotgateway/read"); req.query({
"ids": [
"Channel1.Device1.tag1",
"Channel1.Device1.tag2"
]
}); req.headers({"cache-control": "no-cache",
"Accept-Language": "zh-CN,zh;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
"Upgrade-Insecure-Requests": "1",
"Cache-Control": "max-age=0",
"Connection": "keep-alive"
}); req.end(function (res) {
if (res.error) throw new Error(res.error); console.log(res.body);
});
浏览全部变量(native
var http = require("http"); var options = {
"method": "GET",
"hostname": [
"127",
"0",
"0",
"1"
],
"port": "39321",
"path": [
"iotgateway",
"browse"
],
"headers": {
"Connection": "keep-alive",
"Cache-Control": "max-age=0",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
}
}; var req = http.request(options, function (res) {
var chunks = []; res.on("data", function (chunk) {
chunks.push(chunk);
}); res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
}); req.end();
浏览全部变量(request
var request = require("request"); var options = { method: 'GET',
url: 'http://127.0.0.1:39321/iotgateway/browse',
headers:
{ 'cache-control': 'no-cache',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36',
'Upgrade-Insecure-Requests': '1',
'Cache-Control': 'max-age=0',
Connection: 'keep-alive' } }; request(options, function (error, response, body) {
if (error) throw new Error(error); console.log(body);
});
浏览全部变量(unirest
var unirest = require("unirest"); var req = unirest("GET", "http://127.0.0.1:39321/iotgateway/browse"); req.headers({"cache-control": "no-cache",
"Accept-Language": "zh-CN,zh;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
"Upgrade-Insecure-Requests": "1",
"Cache-Control": "max-age=0",
"Connection": "keep-alive"
}); req.end(function (res) {
if (res.error) throw new Error(res.error); console.log(res.body);
});
最新文章
- python读取excel并制表输出
- MySQL zabbix
- SVN命令模式批量更新多个项目文件
- linux安装时出现your cpu does not support long mode的解决方法
- C语言运算符表
- 《算法导论》习题解答 Chapter 22.1-6(求universal sink 通用汇点)
- 利用ASP.NET MVC源代码调试你的应用程序[转]
- 常用的dos命令之简略总结
- 如何往IE工具条添加按钮(转载)
- ajax get/post
- iOS基础 - 定时器
- Nethogs - 网络流量监控工具
- java基础知识——网络编程、IO流
- 数据分析三剑客之pandas
- jmeter接口测试-GET请求路径中包含特殊字符或中文导致Response400报错
- git笔记(2)-常见命令的使用(详解待续)
- hdu 2815 Mod Tree (exBSGS)
- 由百度 “PHP薪资” 引发的思考
- 一文读懂遗传算法工作原理(附Python实现)
- (1.6)MySQL执行计划