
var??https=require("https");
var?querystring=require("querystring")
var?postData=querystring.stringify({
????'context':'測試數據最后一次!',
????'cid':348,
????'mid':8837,
})
var?options={
????protocol:'https:',
????hostname:'www.xianlaiwan.cn',
????port:443,
????path:'/course/docomment',
????method:'post',
????headers:{
????????'Accept':?'application/json,?text/javascript,?*/*;?q=0.01',
????????'Accept-Encoding':?'gzip,?deflate',
????????'Accept-Language':?'zh-CN,zh;q=0.9,en;q=0.8',
????????'Cache-Control':?'no-cache',
????????'Connection':?'keep-alive',
????????'Content-length':?postData.length,
????????'Cookie':'[]',
????????'Host':?'www.xianlaiwan.cn',
????????'Pragma':?'no-cache',
????????'Referer':?'http://www.xianlaiwan.cn/learn/348',
????????'User-Agent':?'Mozilla/5.0?(Macintosh;?Intel?Mac?OS?X?10_12_4)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Chrome/69.0.3497.92?Safari/537.36',
????????'X-Requested-With':?'XMLHttpRequest'
????}
}
var??req=https.request(options,function?(res)?{
????console.log(res.statusCode)
????console.log(JSON.stringify(res.headers))
????res.on('data',?function(chunk){
????????console.log(Buffer.isBuffer(chunk));
????????console.log(typeof?chunk);
????});
????res.on('end',?function()?{
????????console.log('評論完畢');
????});
});
req.on('error',?function(e)?{
????console.log('Error'?+?e.message);
})
req.write(postData);
req.end();
2018-10-16
nodejs 有專門的https的語法