post提交报404错误
Status:404
headers:{"server":"nginx","date":"Tue, 11 Apr 2017 06:39:45 GMT","content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","connection":"keep-alive","vary":"Accept-Encoding, Accept-Encoding","expires":"Thu, 19 Nov 1981 08:52:00 GMT","cache-control":"no-store, no-cache, must-revalidate, post-check=0, pre-check=0","pragma":"no-cache","content-encoding":"gzip"}
true
object
评论完毕
一直是这样的提示
代码是这样的
var http = require("http"); var querystring = require("querystring"); var postData = querystring.stringify({ 'content':'hhhhhhhhhhhhhhhh', 'cid':8837 }) var options = { hostname:'www.imooc.com', port:80, path:'/course/docoment', 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=697fe7b1-5085-4cdb-9802-1e93e91171fc; imooc_isnew_ct=1490600008; loginstate=1; apsid=ZiMzk3OWE2MmQ1N2I0YWM0NTM0NzRjMGJiNWIyNWIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANDc4MDg3NQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGIwZDcxNjFkODkzZTRlYzE5M2RmNzc2ZGQwYjU3M2JlsB%2FfWLAf31g%3DOT; PHPSESSID=h5qehjh46s1uvaesimfd6n2dt3; IMCDNS=0; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1491541877,1491542023,1491542065,1491785577; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1491887901; imooc_isnew=2; cvde=58ead76900168-162', 'Host':'www.imooc.com', 'Origin':'http://www.imooc.com', 'Referer':'http://www.imooc.com/video/6687', 'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36', 'X-Requested-With':'XMLHttpRequest' } }; 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(){ console.log('评论完毕'); }) }) req.on('error',function(e){ console.log('Error' + e.message) }) req.write(postData); req.end();