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

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();


正在回答

2 回答

请求头 path = '/course/docomment'  少了个m

0 回复 有任何疑惑可以回复我~
#1

慕粉1600211844 提问者

非常感谢!
2017-04-12 回复 有任何疑惑可以回复我~

404没找到服务器资源 也就是你的请求路径错了 检查path是否正确

0 回复 有任何疑惑可以回复我~

举报

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

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

进入课程

post提交报404错误

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信