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.xianlaiwan.cn/error/noexists","connection":"keep-alive","content-type":"text/html","content-length":"154"}
true
object
finish
?
2018-03-27
在你的 headers 里面有一個Upgrade-Insecure-Requests :1,可能是跟這個有關;
試試把第 1 行改成 var http = require(‘https’);然后 options 里的 port 改成 443 ;
再不行就百度一下?Upgrade-Insecure-Requests :1 這個是什么...
2018-03-01
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.xianlaiwan.cn',
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.xianlaiwan.cn%252F%7C1519836300; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1519851938; cvde=5a8334ce553ee-826',
'Host':'www.xianlaiwan.cn',
'Pragma':'no-cache',
'Referer':'http://www.xianlaiwan.cn/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()