亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

運行后能生成評論,但評論顯示是亂碼,求指教

var?http?=?require('http');
var?querystring?=?require('querystring');

var?postData?=?querystring.stringify({
	'content':'老師講得真好,這是追評!',
	'cid':348,
});

var?options?=?{
	hostname:'www.xianlaiwan.cn',
	port:80,
	path:'/course/docomment',
	method:'POST',
	headers:{
		'Accept':'application/json,?text/javascript,?*/*;?q=0.01',
		'Accept-Encoding':'gzip,deflate,sdch',
		'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=bccbd401-fc48-47c0-8ac0-72fccc9681be;?imooc_isnew_ct=1474427933;?					loginstate=1;?apsid=gyYjE4MDEcd7b1393990c78efdeebff3968=1482889141',
		'Host':'www.xianlaiwan.cn',
		'Origin':'http://www.xianlaiwan.cn',
		'Referer':'http://www.xianlaiwan.cn/comment/348',
		'User-Agent':'Mozilla/5.0?(Windows?NT?6.1)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Chrome/31.0.1650.63?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();

http://img1.sycdn.imooc.com//586322de0001df2607910100.jpg

運行后也沒有執行console.log('評論完畢!')http://img1.sycdn.imooc.com//586323780001171a06430179.jpg

求指教,謝謝!

正在回答

2 回答

應該是你的逗號吧,我能看到的


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

風魔大王 提問者

已經解決了,之前是用dw編輯的,現在用sublime text 3 打開也看到中文亂碼,直接在sublime上改就好了,之前的中文字符不兼容的問題現在也解決了。只有你回答,就采納你吧,謝謝!
2016-12-28 回復 有任何疑惑可以回復我~

這個可能是你的編輯器默認的編碼不是utf-8吧, 默認好像一般都是ANSI編碼,你可以看一下

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

舉報

0/150
提交
取消
進擊Node.js基礎(一)
  • 參與學習       219329    人
  • 解答問題       982    個

本視頻教程帶你揭開Node.js的面紗,帶你走進一個全新世界

進入課程

運行后能生成評論,但評論顯示是亂碼,求指教

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號