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:'idcbgp.cn', 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':'idcbgp.cn', 'Origin':'http://idcbgp.cn', 'Referer':'http://idcbgp.cn/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();
2017-04-11
請求頭 path = '/course/docomment' ?少了個m
2017-04-12
404沒找到服務器資源 也就是你的請求路徑錯了 檢查path是否正確