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

status: 302

Status: 302

headers: {"via":"1.1 10.10.40.10 (McAfee Web Gateway 7.7.2.5.0.24352)","date":"Wed, 28 Feb 2018 22:12:22 GMT","server":"nginx","x-cache":"MISS from 10.10.40.10","location":"http://www.imooc.com/error/noexists","connection":"keep-alive","content-type":"text/html","content-length":"154"}

true

object

finish

 


正在回答

2 回答

在你的 headers 里面有一个Upgrade-Insecure-Requests :1,可能是跟这个有关;

试试把第 1 行改成 var http = require(‘https’);然后 options 里的 port 改成 443

再不行就百度一下 Upgrade-Insecure-Requests :1 这个是什么...

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

var http = require('http')

var querystring = require('querystring')


var postData = querystring.stringify({

'content':'hope we have next level NODE class soon, Thanks',

'mid': 8837

})


var options={

hostname: 'www.imooc.com',

port:80,

path: 'course/document',

method: 'POST',

headers:{

'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',

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

'Accept-Language':'en-US,en;q=0.9',

'Cache-Control':'max-age=0',

'Connection':'keep-alive',

'Content-Length': postData.length,

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

'Cookie':'PHPSESSID=us4mgnce4jjvr0ofcj9jaf8900; imooc_uuid=bc3f5a87-a4a6-437a-9af6-224b19ecb5a8; imooc_isnew_ct=1518548174; loginstate=1; apsid=NiODk1YzlkYzBjYTZmZTI2MGE3ZDdlNTM1NTQwYjkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANTUyNTg5NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABqYW1lc3dtaW5nQHlhaG9vLmNvbQAAAAAAAAAAAAAAADU4Mjg4MzYxNmNhZmY2NjdmMjk0YWY3ZGMyNjc3OWFmmkKDWppCg1o%3DZD; imooc_isnew=2; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1518549455,1518553858,1519239544; IMCDNS=0; UM_distinctid=161d85377ad5fe-0676f37ad1a109-a35346f-100200-161d85377af19a; CNZZDATA1261110065=278279359-1519747835-https%253A%252F%252Fwww.imooc.com%252F%7C1519836300; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1519851938; cvde=5a8334ce553ee-826',

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

'Pragma':'no-cache',

'Referer':'https://www.imooc.com/video/8837',

'Upgrade-Insecure-Requests':'1',

'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 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('finish')

})

})


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

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

})

req.write(postData);

req.end()


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

举报

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

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

进入课程
意见反馈 帮助中心 APP下载
官方微信