报错:Errorgetaddrinfo ENOTFOUND http://www.imooc.com http://www.imooc.com:80 求解!!!


var http = require('http');

var querystring = require('querystring');

var postData = querystring.stringify({

'content': '慕课网66666(test~test~test~)',

'cid': 8837

});


var options = {

hostname: 'http://www.imooc.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',

'Content-Length': postData.length,

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

'Cookie': 'PHPSESSID=jborgj9jedn0sv7b5b70l570s1; imooc_uuid=6b71cd9c-5134-4a73-9739-bb6c390ba12b; imooc_isnew=1; imooc_isnew_ct=1507100666; loginstate=1; apsid=IxZGFkOTYyYzUyYmI2ZTNkNjhkMWYwZmU5YTdkZGIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMzA2NzY3MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABzdXBlcm1hbmR5ZEBzaW5hLmNvbQAAAAAAAAAAAAAAADE1YzZhYzQ3MDMwZjYzY2JmNTVjNjE0NzI3ZWZjMTNmR4jUWUeI1Fk%3DYm; last_login_username=supermandyd%40sina.com; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1507100667; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1507100743; cvde=59d487faa24a0-10',

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

'Origin': 'http://www.imooc.com',

'Proxy-Connection': 'keep-alive',

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

'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Mobile 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();


DYD_study
浏览 5797回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Node.js