为了账号安全,请及时绑定邮箱和手机立即绑定

我测试的时候返回状态吗为200,但是刷新页面没有出来我通过程序注入的评论,是怎么回事呢

这是我的代码,麻烦帮帮看看

var http = require('http')

var querystring = require('querystring');


var postData = querystring.stringify({

'content':'测试一下刚学的东西',

'cid':348

})

var options = {

hostname:'www.imooc.com',

port:80,

path:'/course/docomment',

metod:'POST',

headers:{

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

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

'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4,ja;q=0.2,sq;q=0.2',

'Connection':'keep-alive',

'Content-Length':97,

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

'Cookie':'/复制的cookie不会有错/',

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

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

'Referer':'http://www.imooc.com/comment/348',

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

'X-Requested-With':'XMLHttpRequest'

}

}

console.log(postData.length);

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

console.log('Status: '+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 (e){


console.log('评论完毕');

})

})

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

console.log('errors:'+e.message)

})

req.write(postData)

req.end()


正在回答

举报

0/150
提交
取消
进击Node.js基础(一)
  • 参与学习       219315    人
  • 解答问题       982    个

本视频教程带你揭开Node.js的面纱,带你走进一个全新世界

进入课程

我测试的时候返回状态吗为200,但是刷新页面没有出来我通过程序注入的评论,是怎么回事呢

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号