大牛给我看看,为什么cmd跑成功了,网页上却没有
var http = require('http');
var querystring = require('querystring');
var postData = querystring.stringify({
'content': 'test',
'cid': 348
});
var options = {
hostname:'www.imooc.com',
port:80,
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.8',
'Connection':'keep-alive',
'Content-Length':postData.length,
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie':'imooc_uuid=1207be4c-10e3-4cae-9650-4924ee9f0875; imooc_isnew_ct=1473588694; loginstate=1; apsid=A2ZGQwMDE2ODViNmEwNDU0ZTI1NzQ1N2MzMjE2M2EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjEwMDEyNwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyODUyNzM1OTJAcXEuY29tAAAAAAAAAAAAAAAAAAAAADhjNjZjODAzMjFiNGI4Yzk5MzU2NzMyM2JkYzVkNzgxy9JDWMvSQ1g%3DOT; last_login_username=285273592%40qq.com; PHPSESSID=qhgl6jp0iekc15qb005hscdl62; IMCDNS=0; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1478313653,1480839816,1480898786; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1480898792; imooc_isnew=2; cvde=5844b8ddac887-3',
'Host':'www.imooc.com',
'Origin':'http://www.imooc.com',
'Referer':'http://www.imooc.com/video/8837',
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'X-Requested-With':'XMLHttpRequest'
}
};
var req = http.request(options, function(res) {
console.log(res.statusCode);
console.log('headers :' + JSON.stringify(res.headers));
res.on('data', function(chunk) {
console.log(Buffer.isBuffer(chunk));
console.log(typeof chunk);
});
res.on('end', function() {
console.log('finish');
});
res.on('error', function(e) {
console.log(e.message);
});
});
req.write(postData);
req.end();