var https = require('https');
var querystring = require('querystring');
//需要发送的参数
let post_data = querystring.stringify({
'image' : image,
})
//建立http请求
let post_req = https.request({
hostname: "aip.baidubce.com",
mathod: "post",
port: 443,
path: `/rest/2.0/ocr/v1/numbers?access_token=${token}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Content-Length': Buffer.byteLength(post_data) //参数长度
}
}, (res) => {
res.setEncoding('utf8');
res.on('data', (d) => {
console.log(d)
});
}).on('error', (e) => {
console.error(e);
});
//在这里写入需要发送的参数
post_req.write(post_data);
post_req.end();
网友评论