各路神仙,到底是啥问题呀。怀疑人生!!

var http = require('http');

var querystring = require('querystring');

var postData = querystring.stringify({

'content': '表白老师表白老师表白老师表白老师',

'mid': 8837

})


var options = {

hostname: 'www.imooc.com',

method: 'POST',

port: 80,

path: '/course/docomment',

headers: {

'Accept': 'application/json, text/javascript, */*; q=0.01',

'Accept-Encoding': 'gzip, deflate, br',

'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,ru;q=0.7,es;q=0.6',

'Connection': 'keep-alive',

'Content-Length': postData.length,

'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',

'Cookie': 'imooc_uuid=adb2e7b3-7efb-41d8-a346-ae32a0066618; imooc_isnew_ct=1506047932; loginstate=1; apsid=k4NGZkZmIyNWQ0N2Q1YzM3MDc4NzNmNTViZTJmMGMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANjE1MDkzOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADYzMGRhNTk2ZmJmNjcwZTM2MzNlOTU0OTQyMzgyOTlmvyMUWr8jFFo%3DMT; PHPSESSID=rqflnitusjio13vqgvu7l9o800; IMCDNS=0; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1511269306,1511424414,1511428174; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1511443098; imooc_isnew=2; cvde=5a16819b9b600-144',

'Host': 'www.imooc.com',

'Origin': 'https://www.imooc.com',

'Referer': 'https://www.imooc.com/video/8837',

'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',

'X-Requested-With': 'XMLHttpRequest'

}

}


var req = http.request(options, function (res) {

console.log('status:' + res.statusCode);

console.log('header', JSON.stringify(res.headers))


res.on('data', function (chunk) {

console.log(Buffer.isBuffer(chunk));

})

res.on('end', function () {

console.log('发布成功!');

})

})


req.on('error', function (error) {

console.log(error.message);

})

req.write(postData);

req.end();

http://img.mukewang.com/5a16ce330001227511480526.jpg

PS:一直报这个错!!QAQ

慕盖茨3379230
浏览 1306回答 2
2回答

ruibin

我刚看了下,这个程序没啥问题。你报错的原因应该是你node的问题,建议重新安装8.x版本的node。

脚本小布

小白一枚,没发现错误。。。。
打开App,查看更多内容
随时随地看视频慕课网APP