提交結(jié)果404是哪里寫錯?
$?node?comment
Status:?404
headers:?{"date":"Fri,?16?Jun?2017?13:24:44?GMT","server":"Apache","content-leng
th":"207","keep-alive":"timeout=5,?max=100","connection":"Keep-Alive","content-t
ype":"text/html;?charset=iso-8859-1"}
true
object
評論完畢!代碼如下:
var?http?=?require('http')
var?querystring?=?require('querystring')
var?postData?=?querystring.stringify({
'content':?'abcdefgh',
'mid':?8837
})
var?options?=?{
hostname:?'www.mooc.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',
'Cache-Control':'no-cache',
'Connection':'keep-alive',
'Content-Length':postData.length,
'Content-Type':'application/x-www-form-urlencoded;?charset=UTF-8',
'Cookie':'imooc_uuid=f76b92a8-ebc3-4fd5-b076-7d400f63f572;?imooc_isnew_ct=1490499978;?loginstate=1;?apsid=kzZTM1ODUxNzQwMTRhMWVmMWI3MzQ1ZTdjNWM2YzcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANTIyMTEwOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADlmMTUzYTQ4NmZiMjA2NjQ4MWVjNzM4Mjc0YTY0YjI0Yh89WWIfPVk%3DND;?PHPSESSID=lg7c6rqna2thgs8bffarns6g00;?IMCDNS=0;?Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1497580726,1497596581,1497596615,1497615629;?Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1497615876;?imooc_isnew=2;?cvde=5943cd12c5f9b-19',
'Host':'idcbgp.cn',
'Origin':'http://idcbgp.cn',
'Pragma':'no-cache',
'Referer':'http://idcbgp.cn/video/8837',
'User-Agent':'Mozilla/5.0?(Windows?NT?10.0;?Win64;?x64)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Chrome/61.0.3128.2?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-06-16
哎呀是我自己吧網(wǎng)址記錯了,慚愧慚愧!